Datasheet
Chapter 3: EEPROM Tricks and Program Tips · Page 135
' PULSOUT DummyPin, qtiThreshold ' Wait for threshold time
PULSOUT DummyPin, temp ' <--- New wait threshold time
qtiLF = ~qtiSigLeft ' Snapshot of QTI signal states
qtiRF = ~qtiSigRight
.
.
.
Remember, the goal of all this work is to make the program more easily expandable. The
other goal is to make it so that you can move parts of this program to other programs that
follow the same conventions. However, it still has to perform the same functions that it
did before the adjustments.
Example Program: SensorsWithTempVariables.bs2
√ Enter, save, and run SensorsWithTempVariables.bs2
√ Verify that the QTIs work the same as before.
' -----[ Title ]--------------------------------------------------------------
' Applied Robotics with the SumoBot - SensorsWithTempVariables.bs2
' Demonstrates the use of a temporary and multipurpose variable in conjunction
' with DATA, WRITE, and READ for calculating, storing, and using the qti
' threshold value.
' {$STAMP BS2} ' Target = BASIC Stamp 2
' {$PBASIC 2.5} ' Language = PBASIC 2.5
' -----[ I/O Definitions ]---------------------------------------------------
qtiPwrLeft PIN 10 ' Left QTI on/off pin P10
qtiSigLeft PIN 9 ' Left QTI signal pin P9
qtiPwrRight PIN 7 ' Right QTI on/off pin P7
qtiSigRight PIN 8 ' Right QTI signal pin P8
DummyPin PIN 6 ' I/O pin for pulse-decay P6
IrLedLF PIN 4 ' Left IR LED connected to P4
IrSenseLF PIN 11 ' Left IR detector to P11
IrLedRF PIN 15 ' Right IR LED connected to P15
IrSenseRF PIN 14 ' Right IR detector to P14
IrLedLS PIN 2 ' Left IR LED connected to P2
IrSenseLS PIN 1 ' Left IR detector to P1