I would be explaining about making a line follower, using 3 and 2 sensors. I would also be telling the advantage of using 3 sensors over two sensors.
Prerequisites :
1) Have a sensor circuit ready. You can check my post to know how to make a sensor ckt.
2) Have microcontroller (I would be using atmega8). and a motor driver ready.
Setup of sensors:
Have the sensors setup on the chassis in such a way that center sensor is atleast 2cm away from left and right sensor.( Why 2cm you will know later).
Now the LOGIC part: Assuming that arena is white in colour and line is black in colour.
L C R Direction
1 0 1 Forward [ both motors move in same direction]
0 0 1 Left [ only right motor moves]
1 0 0 right [only left motor moves]
0 0 0 Forward. ( we have encountered a junction over here)
Code to be written :
#include
int L; //left sensor connected to 1st pin of Portc, which is PINC.0
int R;// right sensor connected to 2nd pin of Portc, Pinc.1
int C;// center sensor connected to 3rd pin of Portc, Pinc.2
main()
{
if(L==1&&C==0&&R==1)
{
PORTD=0xAA;
}
if(L==0&&C==0&&R==1)
{
PORTD=0x02;
}
if(L==1&&C==0&&R==1)
{
PORTD=0x88;
}
if(L==1&&C==0&&R==1)
{
PORTD=0xAA;
}
Motors are connected to PORTD pins.
When PORTD=0xAA;
AA stands in hex as 10101010 [ Most significant bit to least significant bit]
So the motor pins are connected as follows: Consider only the first four bits/pins, bcz we wont be using the last four bits/pins.
PIND.0= R-;
PIND.1= R+;
PIND.2=L-;
PIND.3=L+;
When R+,L+ are high. Both the motors would rotate in one direction.
When R+ is high, rest ground. Only the right motor would rotate.
Same thing for rest all.
I hope you did understand the code . I will be posting the ckt of it shortly.
If any queries please ask me.
16 comments:
I would like to invite you to join blogging Social Networking
IEDig.com
which helps you to get more visitors to your blogs and you get the chance
to meet other celebrity bloggers.
Join IEDig.com
wonderful...................................................
thank for share, it is very important . ̄︿ ̄..................................................
may the blessing be with you.........................................
pleasure to find such a good artical! please keep update!! ........................................
wonderful...................................................
Better late than never. ........................................
獲益不少,謝謝分享!............................................................
所有的資產,在不被諒解時,都成了負債..................................................................
Judge not a book by its cover.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
nice job! waiting for your new artical.............................................................
This is not the first of your posts I've read, and you never cease to amaze me. Thank you, and I look forward to reading more.
Study in USA | Study in UK
This is not the first of your posts I've read, and you never cease to amaze me. Thank you, and I look forward to reading more.
Education Consultants karachi
It’s glad to see good information being convey. Its a very nice written, and i really like these blog. Thanks for the info.
UK Education Consultants
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
Web Design
You have some interesting thoughts! Perhaps we should contemplate about attempting this myself.
Web Hosting
Post a Comment