Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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
{
*****************************************************************************
* 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