SUMOBOT MOTION CONTROL
The next task is to link the SumoBot robot's ability to "see" with the motors so that an
object – the opponent – can be tracked.
demonstration of linking IR object control to the SumoBot motors.
' SumoBot_4.2_IR_Scan.BS2
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ I/O Definitions ]-------------------------------------------------
LMotor
PIN
RMotor
PIN
LfIrOut
PIN
LfIrIn
PIN
RtIrOut
PIN
RtIrIn
PIN
' -----[ Constants ]-------------------------------------------------------
LFwdFast
CON
LFwdSlow
CON
LStop
CON
LRevSlow
CON
LRevFast
CON
RFwdFast
CON
RFwdSlow
CON
RStop
CON
RRevSlow
CON
RRevFast
CON
' -----[ Variables ]-------------------------------------------------------
irBits
VAR
irLeft
VAR
irRight
VAR
lastIr
VAR
pulses
VAR
' -----[ Initialization ]--------------------------------------------------
Reset:
LOW LMotor
LOW RMotor
' -----[ Program Code ]----------------------------------------------------
Chapter 4: Infrared Object Detection · Page 41
Load and run program 4.2 to see a
13
12
4
11
15
14
1000
800
750
700
500
500
700
750
800
1000
Nib
irBits.BIT1
irBits.BIT0
Nib
Byte
' left servo motor
' right servo motor
' left IR LED output
' left IR sensor input
' right IR LED output
' right IR sensor input
' left motor fwd; fast
' left motor fwd; slow
' left motor stop
' left motor rev; slow
' left motor rev; fast
' right motor fwd; fast
' right motor fwd; slow
' right motor stop
' right motor rev; slow
' right motor rev; fast
' storage for IR target data
' info from last reading
' counter for motor control
' initialize motor outputs
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers