Parallax Boe-Bot Assembly page 50

Mini-sumo robotics assembly documentation and programming
Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Page 40 · SumoBot – Mini Sumo Robotics
' -----[ Variables ]-------------------------------------------------------
irBits
VAR
irLeft
VAR
irRight
VAR
' -----[ Program Code ]----------------------------------------------------
Main:
DO
FREQOUT LfIrOut, 1, 38500
irLeft = ~LfIrIn
FREQOUT RtIrOut, 1, 38500
irRight = ~RtIrIn
DEBUG HOME,
"L
R", CR,
"----", CR,
BIN1 irLeft, "
PAUSE 20
LOOP
END
Two bit-sized variables are declared to store the value of each IR detector output. The
command FREQOUT LfIrOut, 1, 38500 sends the [unfiltered] modulation signal
to the left IR LED, causing it to flash on and off rapidly. The harmonic contained in this
signal either bounces off an object, or not. If it bounces off an object and is seen by the
IR detector, the IR detector sends a low signal to I/O pin LfIrIn . Otherwise, the IR
detector sends a high signal to LfIrIn . The bitwise invert operator (~) is used so that a
"hit" (reflection from the opponent) is indicated by "1" and a "miss" is indicated by a "0."
So long as the next command after the FREQOUT command is the one testing the state of
the IR detector's output, it can be saved as a variable value in RAM. This is possible as
the IR detector output is held active a short time after the signal goes away. The
statement irLeft = ~LfIrIn checks LfIrIn , and saves the value ("1" for hit or "0"
for miss) in the irLeft bit variable. This process is repeated for the other IR pair, and the
IR detector's output is saved in the irRight variable. The DEBUG statement then displays
the values in the Debug Terminal.
Nib
irBits.BIT1
irBits.BIT0
", BIN1 irRight
' storage for IR target data
' modulate left IR LED
' read input (1 = target)
' modulate right IR LED
' read input (1 = target)

Advertisement

Table of Contents
loading

This manual is also suitable for:

QuadcrawlerToddlerSumobotHexcrawler

Table of Contents