ObeyIrCommand:
select case
keyPressed
case
KEY_UP
:
gosub
GoForward
case
KEY_DOWN
:
gosub
GoBackwards
case
KEY_LEFT
:
gosub
TurnLeft
case
KEY_RIGHT
:
gosub
TurnRight
case
KEY_POWER
:
gosub
StopMotors
case
KEY_0
: motorSpeed = 70
case
KEY_1
: motorSpeed = 90
case
KEY_2
: motorSpeed = 110
case
KEY_3
: motorSpeed = 130
case
KEY_4
: motorSpeed = 150
case
KEY_5
: motorSpeed = 170
case
KEY_6
: motorSpeed = 190
case
KEY_7
: motorSpeed = 210
case
KEY_8
: motorSpeed = 230
case
KEY_9
: motorSpeed = 255
else
:
return
end
select
gosub
WaitWhileKeyHeld
return
GoForward:
serout
LeftMotor,T2400,("A",motorSpeed)
serout
RightMotor,T2400,("C",motorSpeed)
return
GoBackwards:
serout
LeftMotor,T2400,("C",motorSpeed)
serout
RightMotor,T2400,("A",motorSpeed)
return
TurnLeft:
serout
LeftMotor,T2400,("C",motorSpeed)
serout
RightMotor,T2400,("C",motorSpeed)
return
TurnRight:
serout
LeftMotor,T2400,("A",motorSpeed)
serout
RightMotor,T2400,("A",motorSpeed)
return
StopMotors:
pulsout
LeftMotor,6
' Brake Left Motor
pulsout
RightMotor,6
' Brake Right Motor
return
WaitWhileKeyHeld:
' Wait until IR key released
timeout = 0
do
inc
timeout
if
IR_SIGNAL = 0
then
timeout = 0
end if
pause
1
loop until
timeout > 25
return
Summary of Contents for Versabot
Page 1: ...The Versabot Manual July 2009...
Page 23: ...Step 03 Step 04 Step 05...
Page 24: ...Step 06 Step 07 Step 08...
Page 25: ...Step 09 Step 10 Step 11...
Page 26: ...Step 12 Step 13...