Datasheet
Page 162ยท Applied Robotics with the SumoBot
RETURN
' -----[ Subroutine - Pulse_Servos ]------------------------------------------
Pulse_Servos:
' Pulse to left servo
LOOKUP maneuver, [ FS_CCW, FS_CW, FS_CW, FS_CCW,
NO_ROT, FS_CCW, LS_CCW, FS_CCW ], temp
PULSOUT ServoLeft, temp
' Pulse to right servo
LOOKUP maneuver, [ FS_CW, FS_CCW, FS_CW, FS_CCW,
FS_CW, NO_ROT, FS_CW, LS_CW ], temp
PULSOUT ServoRight, temp
' Pause between pulses (remove when using IR object detectors + QTIs).
PAUSE 20
RETURN
' -----[ Subroutine - Read_Object_Detectors ]---------------------------------
Read_Object_Detectors:
FREQOUT IrLedRS, 1, IrFreq ' Right side IR LED headlight
irRS = ~IrSenseRS ' Save right side IR receiver
FREQOUT IrLedRF, 1, IrFreq ' Repeat for right-front
irRF = ~IrSenseRF
FREQOUT IrLedLF, 1, IrFreq ' Repeat for left-front
irLF = ~IrSenseLF
FREQOUT IrLedLS, 1, IrFreq ' Repeat for left side
irLS = ~IrSenseLS
RETURN
Your Turn - Orchestrating a Multi-Step Maneuver
Here is a two-step maneuver. The first DO UNTIL...LOOP curves toward the opponent.
If it doesn't see the opponent with both eyes after 15 pulses, it moves on to the second
step. In the second step, the SumoBot rotates in place (
maneuver = RotateLeft) until
either both IR detectors can see the opponent or until 30 pulses have completed. Again,
that way, the SumoBot won't indefinitely rotate in place.