Pbasic question
Archiver
Posts: 46,084
The line follower example posted at the parallax site uses the
following code to read the IR sensors:
Read_Line_Follower:
lfBits = 0 ' clear last reading
FOR ledPos = 2 TO 6
OutL.LowBit(ledPos) = LEDon ' turn the LED on
PAUSE 1 ' allow sensor to read
lfBits.LowBit(ledPos) = In9 ^ LFmode ' record the sensor
reading
OutL = OutL | %01111100 ' turn LEDs off
NEXT
lfBits = lfBits >> 2 ' shift bits to zero
index
RETURN
I've read through the manual, but haven't figured out what's the
reason/advantage of using:
lfBits.LowBit(ledPos)
instead of
lfBits.Bit(ledPos) ????
lfbits is a byte, not an array.
Any ideas?
following code to read the IR sensors:
Read_Line_Follower:
lfBits = 0 ' clear last reading
FOR ledPos = 2 TO 6
OutL.LowBit(ledPos) = LEDon ' turn the LED on
PAUSE 1 ' allow sensor to read
lfBits.LowBit(ledPos) = In9 ^ LFmode ' record the sensor
reading
OutL = OutL | %01111100 ' turn LEDs off
NEXT
lfBits = lfBits >> 2 ' shift bits to zero
index
RETURN
I've read through the manual, but haven't figured out what's the
reason/advantage of using:
lfBits.LowBit(ledPos)
instead of
lfBits.Bit(ledPos) ????
lfbits is a byte, not an array.
Any ideas?
Comments
as such. For Nibs, Bytes and Words, the LowBit modifier allows access to
individual bits and works well for the Line Follower code.
There is no Bit modifier for variables, so the syntax you suggested would not
compile.
-- Jon Williams
-- Applications Engineer, Parallax
In a message dated 4/12/02 2:11:11 PM Central Daylight Time,
Paul.h.garcia@B... writes:
> I've read through the manual, but haven't figured out what's the
> reason/advantage of using:
>
> lfBits.LowBit(ledPos)
>
> instead of
>
> lfBits.Bit(ledPos) ????
>
> lfbits is a byte, not an array.
>
> Any ideas?
>
[noparse][[/noparse]Non-text portions of this message have been removed]
The ledPos is an array, and the information you are looking for is in
Chapter 4 of the Basic Stamp Manual,
sections Defining Arrays, and Aliases and Modifiers pages 51 thru 55 in the
bound manual, and pages 53 thru 57 in
the PDF manual.
Have Some Fun !!
Dale Fleischmann
md10bldr wrote:
> The line follower example posted at the parallax site uses the
> following code to read the IR sensors:
>
>
> Read_Line_Follower:
> lfBits = 0 ' clear last reading
> FOR ledPos = 2 TO 6
> OutL.LowBit(ledPos) = LEDon ' turn the LED on
> PAUSE 1 ' allow sensor to read
> lfBits.LowBit(ledPos) = In9 ^ LFmode ' record the sensor
> reading
> OutL = OutL | %01111100 ' turn LEDs off
> NEXT
> lfBits = lfBits >> 2 ' shift bits to zero
> index
> RETURN
>
>
>
> I've read through the manual, but haven't figured out what's the
> reason/advantage of using:
>
> lfBits.LowBit(ledPos)
>
> instead of
>
> lfBits.Bit(ledPos) ????
>
> lfbits is a byte, not an array.
>
> Any ideas?
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/