Page 198 ·
Robotics with the Boe-Bot
Example Program: TestPhotoresistorsDividers.bs2
This example program is TestWhiskers.bs2 adapted to the photoresistor dividers. Instead
of monitoring P5 and P7 as we did with the whiskers, we are now monitoring P3 and P6,
which are connected to the photoresistor divider circuits. This program should display a
value of 1 on both sides in a well-lit room. When you cast a shadow over one or both of
the photoresistors, their corresponding values should change to 0.
√
Reconnect power to your board.
√
Enter, save, and run TestPhotoresistorDividers.bs2.
√
Verify that with no shade, both
IN6
and
IN3
store the value 1.
√
Verify that you can use your hand to cast a shadow over each of the
photoresistors and cause its input register to change from 1 to 0.
√
If you are having difficulty, either with getting a shadow to change the input
register to 0 or if the input registers store 0 regardless of whether or not you cast
a shadow over them, see the Photoresistor Divider Troubleshooting box after the
program listing. Work on it until your hand casting a shadow over the
photoresistor reliably changes the state from 1 to 0.
' Robotics with the Boe-Bot - TestPhotoresistorDividers.bs2
' Display what the I/O pins connected to the photoresistor
' voltage dividers sense.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "PHOTORESISTOR STATES", CR,
"Left Right", CR,
"------- --------"
DO
DEBUG CRSRXY, 0, 3,
"P6 = ", BIN1 IN6,
" P3 = ", BIN1 IN3
PAUSE 100
LOOP