hiii guys,
i have prepared a line follower with my friends recently as a part of our project.but we are facing dificulties in the programming as the robo is not taking the sharp right turn.can anybody tell correct programming of the same..i'll be very thankful to you....
This works good it's in basic I used a lm339n for the comparator
Code:
leftsensor var GPIO.0
rightsensor var GPIO.1
leftmotor var GPIO.2
rightmotor var GPIO.4
main:
TRISIO = %0001011
GPIO = 0 ' initialize GPIO port
CMCON0 = 7
high leftmotor
high rightmotor
input leftsensor
input rightsensor
do
if (leftsensor = 0) and (rightmotor = 1) then
high leftmotor
else
low leftmotor
endif
if (rightsensor = 0) and (leftsensor = 1) then
high rightmotor
else
low rightmotor
endif
pause 50
high leftmotor
high rightmotor
pause 50
loop
change the pause 50 to speed it up or slow it down
Here 1 for a 18f1220 in swordfish basic you can use it with 18f1230
Code:
{
*****************************************************************************
* Name : Line Follower *
* Author : [Burt] *
* Notice : Copyright (c) 2009 *
* : All Rights Reserved *
* Date : 2/22/2009 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
Device = 18F1220
Clock = 8
Config OSC = INTIO2 // Use the Internal Oscillator
Include "IntOSC8.bas"
Include "utils.bas"
dim leftsensor as PORTB.0
dim rightsensor as PORTB.1
dim leftmotor as PORTB.2
dim rightmotor as PORTB.3
SetAllDigital
High (leftmotor)
High (rightmotor)
Input (leftsensor)
Input (rightsensor)
While True
If (leftsensor = 0) And (rightmotor = 1) Then
High (leftmotor)
Else
Low (leftmotor)
EndIf
If (rightsensor = 0) And (leftsensor = 1) Then
High (rightmotor)
Else
Low (rightmotor)
EndIf
DelayMS(50)
High (leftmotor)
High (rightmotor)
DelayMS(50)
wend
you need to put the IntOSC8.bas in you swordfish basic user library
I thought I post this to a fast 1 hour line follower **broken link removed****broken link removed****broken link removed**If any one want the circuit I'll post it.