Shop OBEX P1 Docs P2 Docs Learn Events
Use of PINS in 8-bit binary — Parallax Forums

Use of PINS in 8-bit binary

ChcKsssChcKsss Posts: 10
edited 2006-07-06 16:15 in BASIC Stamp
Hey I just got a board of education so I'm not very professional with it yet.
I would like to set all pins in one to a certain binary status for example pins=%0001000.
And later I would like to do binary operators like pins=pins & pins=%00000011.
Until now I just defined the pins like:
Pone PIN 0
Ptwo PIN 1 ..... and so on
but the source code is getting huge if I would write then Pone=Pone & Ptwo=Ptwo... Plus it is not working that way.
So my question is: How can I handle pins in binary. Since this would make things a lot easier.
Thank you in advance for your help
Cindy

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-06 15:03
    Cindy,

    ·· You can set all 8 pins at the same time if they're in the same port group, for example, P0-P7 or P8 through P15.· Just use OUTL or OUTH depending on which group you're on and you can set them with OUTL = value/variable.· Remember, the outputs won't actually be connected if the DIRL register isn't set for these pins to be outputs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ChcKsssChcKsss Posts: 10
    edited 2006-07-06 15:33
    Chris,
    Thank you so much! This helped a lot smile.gif
    But still it doesn't like the line: OUTS = OUTS & OUTS = %00010000
    It gives me the error message : "Expecting binary operator ')' "
    How would you write the line?
    Cindy
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-06 16:15
    Cindy,

    ·· You are sort of double-assigning OUTS in that statement.· A literal version of your command would be:

    OUTS = OUTS &·%00010000

    Of course, the binary byte above could also be a variable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.