Download Print this page

Parallax 29115 Manual page 8

Line follower module

Advertisement

This line of code demonstrates that any nibble, byte or word variable can be treated as an array of bits.
Using .LowBit(index) modifier allows the access (read or write) of any bit in the variable. In this case,
the variable is OutL since the LEDs are connected to Stamp pins P2 through P6. Figure 5 shows the
relationship between the bits in OutL and the LEDs in the Line Follower module.
Figure 5: Line Follower LED Control Bits in OutL (P0...P7)
With the LED lit, the program will PAUSE for one millisecond to give the IR detector time to respond.
The output of the Line Follower module (on P9) is placed into appropriate bit of the variable lfBits. Note
that the Exclusive OR ( ^ ) operator is used on the bit before it is saved. What this does is allow the
program to see the line – be it black-on-white or white-on-black – as a "1." If no line is detected, the
output bit will be zero.
After each bit is recorded, the LEDs are switched off. Note that the current value of OutL is OR'd ( | )
with %01111100 (all LEDs off). This technique allows the program to uses pins 0, 1 and 7 as outputs
without being affected by this subroutine. Before returning to the main loop, the value of lfBits is
shifted two bits to the right. While not required, this process does make display of lfBits and its use in
some algorithms simpler. Figure 6 shows the bits in lfBits at the end of the Read_Line_Follower
subroutine.
Figure 6: lfBits After Shifting
Back in the main code loop, the MoveTo character is used to position the cursor in the DEBUG window,
then the lfBits value is displayed with the BIN5 (binary output, five digits) modifier. With the current
Line Follower bits displayed, GOTO returns the program to Main and process starts over.
Parallax, Inc. • Parallax Line Follower (#29115) • 12/2001
Page 7

Advertisement

loading