Page 206 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 206
Amphibionics 05 3/24/03 8:44 AM Page 185
Chapter 5 / Serpentronic: Build Your Own Robotic Snake
for temp = 1 to num_samples
if ir_input = 0 then
serpentronic.bas
ir_count = ir_count + 1 PROGRAM 5.5
program listing
endif (continued)
next
if ir_count >= threshold then
object_detect = 1
endif
return
'------------------------------------------------------------------------------------------------------------------------------
' subroutine to calibrate I.R. sensors
ir_cal:
If ir_input = 0 then
high led_left
high led_right
endif
low led_left
low led_right
If cal_switch = 1 then
pause 50
button_release:
If cal_switch = 1 then
goto button_release
else
Sound piezo,[120,4,90,2,100,2,110,4]
pause 50
goto start
endif
endif
goto ir_cal
185