Parallax Boe-Bot Assembly page 37

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

Advertisement

lbLeft
VAR
lbRight
VAR
' -----[ Program Code ]----------------------------------------------------
Main:
GOSUB Read_Line_Sensors
DEBUG HOME, "LR", CR,
BIN2 lineBits, CR, CR
SELECT lineBits
CASE %00
DEBUG "Continue forward", CLREOL
CASE %01
DEBUG "Spin Left", CLREOL
CASE %10
DEBUG "Spin Right", CLREOL
CASE %11
DEBUG "Back up and turn around", CLREOL
ENDSELECT
GOTO Main
END
' -----[ Subroutines ]-----------------------------------------------------
Read_Line_Sensors:
HIGH LLinePwr
HIGH RLinePwr
HIGH LLineIn
HIGH RLineIn
PAUSE 1
RCTIME LLineIn, 1, lLine
RCTIME RLineIn, 1, rLine
LOW LLinePwr
LOW RLinePwr
' convert readings to bits
LOOKDOWN lLine, >=[1000, 0], lbLeft
LOOKDOWN rLine, >=[1000, 0], lbRight
RETURN
HOW IT WORKS
This program takes the working QTI code and incorporates into a unified subroutine.
The end of the subroutine converts the analog values from the QTI sensors to a single
nibble value that contains the status of both sensors. Incorporating both sensor readings
into a single variable streamlines the SumoBot robot's border avoidance logic.
Chapter 3: SumoBot Sensors and Border Detection · Page 27
lineBits.BIT1
lineBits.BIT0
' show sensor readings
' display actions
' activate sensors
' discharge caps
' read left sensor
' read right sensor
' deactivate sensors
' 0 = black, 1 = line

Advertisement

Table of Contents
loading

This manual is also suitable for:

QuadcrawlerToddlerSumobotHexcrawler

Table of Contents