Shop OBEX P1 Docs P2 Docs Learn Events
reading IND into a variable — Parallax Forums

reading IND into a variable

kutalinelucaskutalinelucas Posts: 80
edited 2011-07-22 16:53 in BASIC Stamp
Hey guys. This is my first day with the basic stamp and there's just a few questions I'd like to ask if thats ok...

Firstly, is it OK to read a nibble of the bs_2, say p12 -> p15 into a variable with:
Data_lines      VAR   IND
Upper_nibble   VAR   Byte
Upper_nibble = Data_lines
 

...I can't seem to find how to read a port as opposed to reading a PIN, and the above just seems too simple

secondly, if I declaire a byte and store say IND to a variable, will it just pad the top four bits with zeros?

I could post my code to try to explain where I'm going if you think it may help

Cheers

Comments

  • kutalinelucaskutalinelucas Posts: 80
    edited 2011-07-22 13:58
    it's ok...problem solved, I pulled the line high and it seems to trigger.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-22 16:53
    As you've noticed, IND is a predefined variable that corresponds to the 4 I/O pins 15-12 with these treated as a nibble. The Stamp treats all numeric values as 16-bit, so IND, when its value is taken, becomes a 16-bit value with the upper 12 bits set to zero.

    The PIN statement is a sort of fudge. Some places in PBasic require a bit value (like IN3) and others require an I/O pin number (like HIGH 3). PIN allow you to declare a name that can be used in either case and the compiler figures out which one you need from context.
Sign In or Register to comment.