' Robotics with the Boe-Bot - MovementsWithSubroutines.bs2 ' Make forward, left, right, and backward movements in reusable subroutines. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" counter VAR Word FREQOUT 4, 2000, 3000 ' Signal program start/reset. GOSUB Forward GOSUB Left GOSUB Right GOSUB Backward END Forward: FOR counter = 1 TO 64 PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT PAUSE 200 RETURN Left: FOR counter = 1 TO 24 PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 NEXT PAUSE 200 RETURN Right: FOR counter = 1 TO 24 PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT PAUSE 200 RETURN Backward: FOR counter = 1 TO 64 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT RETURN