Shop OBEX P1 Docs P2 Docs Learn Events
trouble Shifting value into a variable — Parallax Forums

trouble Shifting value into a variable

GabrielrotoGabrielroto Posts: 7
edited 2007-11-30 16:26 in BASIC Stamp
OK here's what I got

x VAR Bit
y VAR Bit
z VAR Bit
PersVal VAR Nib

Mainloop1:
AUXIO
x = IN0
y = IN1
z = IN2

DEBUG ? x
DEBUG ? y
DEBUG ? z
DEBUG ? PersVal

DEBUG BIN x, BIN y, BIN z >> PersVal, CR
DEBUG ? PersVal

The three inputs are connected to pushbuttons. I can see the inputs change states in my debug window, but PersVal never gets updated - it remains zero. Is there a way to set the value of PersVal equal to the binary value of the pin states. I'm trying to give PersVal a range of 1 thru 5 using the three pins as binary digits. This is kind of hard to put into words so let me know if it makes sense or just try your best to help. Any response you guys have will be greatly appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-30 15:45
    How about: PersVal = z*4 + y*2 + x
  • GabrielrotoGabrielroto Posts: 7
    edited 2007-11-30 16:26
    I think that'll do it. I just assigned the output numbers to each of my five binary conditions and it works great. Thanks a lot!!
Sign In or Register to comment.