Copyright © Parallax Inc.
Infrared Line Follower Kit (#28034)
v1.0 1/18/2011 Page 7 of 9
' InfraredLineFollower_Simple.bs2
' Displays output states of the Infrared Line Follower using the Debug Terminal.
' {$STAMP BS2}
' {$PBASIC 2.5}
state VAR Byte
DO
state = INL ' Read input state of pins 0-7
DEBUG HOME, "state = %", BIN8 state ' Display states on Debug Terminal
LOOP
Propeller P8X32A Example Code
The program below will test the Infrared Line Follower sensors before they’re used in a line-following
application. Follow the instructions below to test that all 8 sensors are working correctly.
Affix a 3/4" piece of electrical tape on a white piece of paper.
Enter & run InfraredLineFollower_Simple.spin.
Place S0 over the electrical tape, and the other sensors over the white paper.
The Parallax Serial Terminal should read %00000001 and the S0 LED should be off.
Repeat this process until all eight sensors are tested.
If your sensor doesn’t display a logical 1 when over a black line and logical 0 when over a white line,
check your connections and/or try adjusting the frequency in the Calibration section on page 8.
'' InfraredLineFollower_Simple.spin
'' Displays output states of the Infrared Line Follower using the Parallax Serial Terminal.
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
byte state
OBJ
pst : "Parallax Serial Terminal"
PUB Main
outa[0..7]~ ' Sets pins 0-7 as input
pst.start(115_200) ' Initialize Parallax Serial Terminal
waitcnt(c cnt)
repeat
state := ina[7..0] ' Read the states of pins 0-7
pst.home ' Set cursor to upper left corner
pst.bin(state, 8) ' Display states in PST
waitcnt(clkfreq/200 + cnt)