Page 150 ·
Robotics with the Boe-Bot
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
' -----[ Main Routine ]-------------------------------------------------------
DO UNTIL (instruction = "Q")
READ address, instruction ' Data at address in instruction.
address = a 1 ' Add 1 to address for next read.
SELECT instruction ' Call a different subroutine
CASE "F": GOSUB Forward ' for each possible character
CASE "B": GOSUB Backward ' that can be fetched from
CASE "L": GOSUB Left_Turn ' EEPROM.
CASE "R": GOSUB Right_Turn
ENDSELECT
LOOP
END ' Stop executing until reset.
' -----[ Subroutine - Forward ]-----------------------------------------------
Forward: ' Forward subroutine.
FOR pulseCount = 1 TO 64 ' Send 64 forward pulses.
PULSOUT 13, 850 ' 1.7 ms pulse to left servo.
PULSOUT 12, 650 ' 1.3 ms pulse to right servo.
PAUSE 20 ' Pause for 20 ms.
NEXT
RETURN ' Return to Main Routine loop.
' -----[ Subroutine - Backward ]----------------------------------------------
Backward:
'
Backward
subroutine.
FOR pulseCount = 1 TO 64 ' Send 64 backward pulses.
PULSOUT 13, 650 ' 1.3 ms pulse to left servo.
PULSOUT 12, 850 ' 1.7 ms pulse to right servo.
PAUSE 20 ' Pause for 20 ms.
NEXT
RETURN ' Return to Main Routine loop.
' -----[ Subroutine - Left_Turn ]---------------------------------------------
Left_Turn: ' Left turn subroutine.
FOR pulseCount = 1 TO 24 ' Send 24 left rotate pulses.
PULSOUT 13, 650 ' 1.3 ms pulse to left servo.
PULSOUT 12, 650 ' 1.3 ms pulse to right servo.
PAUSE 20 ' Pause for 20 ms.
NEXT
RETURN ' Return to Main Routine loop.