BS1: reading I/O pins and as a binary byte
Dgswaner
Posts: 795
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
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
Maybe I should have waited to do that......
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster