Shop OBEX P1 Docs P2 Docs Learn Events
Pbasic question — Parallax Forums

Pbasic question

ArchiverArchiver Posts: 46,084
edited 2002-04-15 02:24 in General Discussion
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?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-04-13 05:11
    Almost any variable can be treated as an array without actually declaring it
    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]
  • ArchiverArchiver Posts: 46,084
    edited 2002-04-15 02:24
    Hi;

    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/
Sign In or Register to comment.