Let's Make Robots!

first program good

I am new to programing and i have a question, Is this program rightfor a tracked robot with 2 moters 1 servo 1 led 1 sharp and a small speaker?Also it is a picaxe 28x2.this is the program.

Symbol dangerlevel = 70
symbol turn = 300
symbol servo_turn = 700

main:
readadc 0, b0
if b0 < dangerlevel then
gosub nodanger
else
gosub whichway
end if
goto main


nodanger:
high B.5 : high B.6 : low B.4 : low B.7
return


whichway:
gosub noise
gosub totalhalt
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
sound B.1, (100, 30)low 1
high B.2
wait 1
gosub lturn
pause servo_turn
low B.2
sound B.1, (105, 60)low 1
readadc 0, b1
gosub totalhalt


gosub rturn
pause servo_turn
sound B.1, (100, 30)low 1
high B.2
wait 1
low B.2
sound B.1, (105, 60)low 1
readadc 0, b2
gosub totalhalt


if b1<b2 then
gosub body_lturn
else
gosub body_rturn
end if
return

body_lturn:
high B.6 : low B.5 : low B.7 : high B.4
pause turn : gosub totalhalt
return

body_rturn:
high B.5 : low B.6 : low B.4 : high B.7
pause turn : gosub totalhalt
return

rturn:
servo B.0, 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
return

lturn:
servo B.0, 200
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
return

totalhalt:
low B.4 : low B.5 : low B.6 : low B.7
Servo B.0,150
wait 1
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2
pause 100
high B.2
pause 100
low B.2

return

noise:

sound B.1, (30,110)low 1

return

it is301bytes

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

there's guaranteed to be something wrong.(who knows what) but when you upload it, you'll see it work different than you had planned.

q