PDA

View Full Version : line follower - IR sensor



shirleyz
- 28th May 2008, 12:07
hi

i'm using the pic16f877a for my line follower. servo motor is used to control the wheel. i'm using 3 IR to detect the black line....so how i need to write the codes using picbasic??

'porta.0 is Right Motor
'porta.1 is Left Motor
'portb.0 is Right Sensor
'portb.1 is Center Sensor
'portb.2 is Left Sensor
'white line = 1
'black line = 0

'L C R
'0 0 0 MF
'0 0 1 TL
'0 1 0 MF
'0 1 1 TL
'1 0 0 TR
'1 0 1 MF
'1 1 0 TR
'1 1 1 SC

If (RS = 0) and (CS = 0) and (LS = 0) Then MF
If (RS = 1) and (CS = 0) and (LS = 0) Then TL
If (RS = 0) and (CS = 1) and (LS = 0) Then MF
If (RS = 1) and (CS = 1) and (LS = 0) Then TL
If (RS = 0) and (CS = 0) and (LS = 1) Then TR
If (RS = 1) and (CS = 0) and (LS = 1) Then MF
If (RS = 0) and (CS = 1) and (LS = 1) Then TR
If (RS = 1) and (CS = 1) and (LS = 1) Then SC

mackrackit
- 28th May 2008, 14:35
Hi,

Here is a page that might get you going.
http://www.rentron.com/Micro-Bot/IR_Nav.htm

Use two IR instead of three, but that is all you need to follow a line.

shirleyz
- 29th May 2008, 12:14
thank you so much...this link is really useful to me...