This is the code that will tell the buggy to follow a trackdesignated by strips of magnetic tape.
main:
readadc 1, b1 'read the analogue values from
readadc 0, b2 'left LDR (b1), and right LDR (b2)debug b1debug b2
low 1 'code for motor activation
high 2
low 3
high 4
start:
readadc 1, b1 'read the analogue values from
readadc 0, b2 'left LDR (b1), and right LDR (b2)debug b1
debug b2
if b1 > 89 then 'This is allocates values to b3 and b4 depending
b3 = 1 'on the input coming from the LDR
else b3 = 0
end if
if b2 > 89 then
b4 = 1
else b4 = 0
endif
b5 = b4 * 2 + b3 'Arithmic condition that will allow the PICAXE 'to decide whach case to
choose.select case b5
case 0
low 1 'code for motor activation
high 2
low 3
high 4
case 1 'If the left LDR goes over magnetic
low 1 'tape then the motor will stop.
low 2
low 3
high 4
case 2
low 3
low 4
low 1 'code for motor activation
high 2
case 3
low 1
low 2
low 3
low 4
endselect
goto start
As you can see this is only a sub module.
The coding needed to follow the second objective is currently under development.
Thursday, 25 March 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment