Tuesday 23 March 2010

Program Ideas

Here is the first experimental code written for this project
___________________________________________________

'For the mode toggle switch
main:

if pin7 = 1 then 'when pin7 is high
if b0 = 0 then 'if bo is low then...
b0 = 1 'make it high

else
b0 = 0 'otherwise make it low

endif
endif

pause 100 'pause to account for human reactions when pressing the switch

'Sensor Encoding
main1:
readadc 1, b1 'Sensor LEFT to b1
readadc 2, b2 'Sensor MIDDLE to b2
readadc 3, b3 'Sensor RIGHT to b3

'Line follow mode

if b0 = 0 then 'Move forward initially
high 1
low 2
high 3
low 4

do while b1 > 20 'Calibrate - turn RIGHT when right sensor activated
high 1
low 2
low 3
high 4
goto main1
loop

do while b3 > 20 'Calibrate - turn LEFT when right sensor activated
low 1
high 2
high 3
low 4
goto main1
loop

endif

'Symbol read mode

if b0 = 1 then 'Move forward initially
high 1
low 2
high 3
low 4

'Move Forward RIGHT Forward
if b1 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000

low 1
high 2
high 3
low 4
pause 300 'Calibrate

high 1
low 2
high 3
low 4
pause 1000

endif

'Move Forward STOP Backwards
if b2 > 20 then 'Calibrate
high 1
low 2
high 3
low 4
pause 1000

low 1
low 2
low 3
low 4
pause 1000

low 1
high 2
low 3
high 4
pause 1000

endif

'Move Forward LEFT Forward
if b3 > 20 then 'Calibrate

high 1
low 2
high 3
low 4
pause 1000

high 1
low 2
low 3
high 4
pause 300 'Calibrate

low 2
high 3
low 4
pause 1000

endif
endif

goto main
___________________________________________________

Posted by Mark Hawkins

No comments:

Post a Comment