More buttons and LED's
K. Reichman
Posts: 9
Hi,
Please help me. I must have seven buttons on BS2. When I touch one button, BS2 must sent on serial character "1", and so on until character "7". There is 2 problems: 1. When I release one button, I want BS2 to continue to send the character, until I press the other button, .... 2. On each buttons is atached one LED. I want LED remain on after button is released.
PLEASE HELP ME !!!
Thanks
Valentin
Please help me. I must have seven buttons on BS2. When I touch one button, BS2 must sent on serial character "1", and so on until character "7". There is 2 problems: 1. When I release one button, I want BS2 to continue to send the character, until I press the other button, .... 2. On each buttons is atached one LED. I want LED remain on after button is released.
PLEASE HELP ME !!!
Thanks
Valentin
Comments
Main:
· select =·NCD (INL & %01111111)
· IF·select = 0 THEN Main············ ' try again if none pressed
· OUTH = %00000000··················· ' clear old LED
· select = select - 1················ ' z-align
· HIGH select + 8···················· ' light new LED
· SEROUT Sio, Baud, [noparse][[/noparse]"0" + select]··· ' transmit character
· GOTO Main
P0 - P7 are the button inputs (active high), P8 - P14 are the LED outputs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/15/2005 1:15:26 PM GMT
I read DCD sets a bit of a Word using a 4 bit value, that is it sets any bit 0 through 15 for the integer value 0 through 15 given as its input.
INL is an 8 bit value so bits 4 thru 7 are not looked at by the command.
results would be 2,4 16 and 256 for bit 0,1,2,3
Select is also a keyword so you cant use it as a variable
Could you just use
main:
ledvar=INL & %01111111 'Get the input bit that is set mask to 7 switches
outH=ledvar 'Set the bit to light the led (shift to position first depending on pins used)
output serial character
probbly pause for some delay
goto main
If that's wrong I must be in need of a vacation cause I just cant see how it works.
For the moment, didn't work. Can you send me please a diagram with connection of one button and one LED please?
NCD will return the input that is pressed (+1) -- that way you get one value, even if you accidentally press two buttons.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Tx
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax