Shop OBEX P1 Docs P2 Docs Learn Events
BS1: reading I/O pins and as a binary byte — Parallax Forums

BS1: reading I/O pins and as a binary byte

DgswanerDgswaner Posts: 795
edited 2007-09-14 15:18 in BASIC Stamp
I'm trying to read several pins on a BS1 and I only want to read it as one byte
I'm basically saying w6 = pins
that gives me a 16 bit binary number. "W6 = %0000000001100000"

when I push the button connected to a pin it doesn't seem to have logic as far as the byte produced. I'm sure there is something I'm missing here but I can't figure it out. even if I bebug %B12 and just look at half of the byte it doesn't make sense.

here is an example of what is happening:

W6 = %0000000010000000 pin 7 high only
W6 = %0000000001100000 pin 6 high only
W6 = %0000000001110000 pin 5 high only
W6 = %0000000011110000 pins 7 and 5 high
W6 = %0000000011110000 pins 5,6 and 7 high

If I was reading one pin at a time I could figure out which pin was high, but what if I want to read all 3 pins at once.
I thought that each number was supposed to show the state of a pin O for low 1 for high. what am I missing?
is there a better way to read the I/o pins and send it as a byte?

thanks in advance for any help

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-09-14 06:55
    Dgswaner -

    Reading I/O pins which are floating (not pulled up or down) can result in strange or unexpected pins states. Add appropriate pull-up or pull-down resistors, and see if your results change.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • DgswanerDgswaner Posts: 795
    edited 2007-09-14 13:32
    I'm using a 10K resistor from VDD to the I/O pin to pull them high.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-09-14 13:44
    The BS1 only has 8 pins, so wont your high byte always be zero? And what you said was read the pins as a word, right?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
  • DgswanerDgswaner Posts: 795
    edited 2007-09-14 15:18
    yes the high byte will always read a zero, at least as I under how it works. Well here is the plan. I want to read in the i/o pins and xmit them via RF to my Pink Module. I don't want to have to send data 7 different. so I'm trying to read all 7 i/o pins (the 8th pin is required for sending) all at once. the stamp on the receiving end will separate out each bit and know which pin is high and low. it was my understand from the manual that if i say W6 = pins that reads the value of each pin and creates a byte. O indicating a low 1 indicating a high.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster
Sign In or Register to comment.