Pushbuttons Low to High
T. Pardy
Posts: 6
Hi, I am new to the forum. I just recently bought the stampworks kit, I've had a long time interest in electronics and computers. I came across this kit and thought wow, I'm gonna dive right in. Now for my question, I have noticed that the push buttons on the PDB return a logic 0 when pressed instead of a 1. Is this normal? and if so, could someone explain to me why that is and how I can get them to send a high signal instead? Any help would be greatly appreciated..
thanks,
Travis
thanks,
Travis
Comments
Rick
If you take a look at the PDB schematic on the product page and find the page with the switches on you will see that the buttons are 8 identical circuits. Each button has two resistors associated with it. The 22 Ohm is a standard connection used with most I/O to protect the stamp from high current. The 10 K resistor is low enough to hold the pin in a logic 1 state yet high enough that when the button is pressed it provides a logic 0 while limiting the current between Vdd and Vss to a minimal value.
As Rick pointed out these switches hard wired and cannot be altered , but you can mount your own switch on the breadboard using the same resistor configuration and by swapping Vdd and Vss you would get a logic 0 in the non pressed state and a logic 1 when pressed.
Jeff T.
trav
To read the inverted state of any I/O pin simply place a tilde (~) in front of it. For example, if you use the following code you will see a 1 until you press the button at which point it will become a 0 (assuming your PDB button is connected to P0).
Now, if you make a single change as below, it will now return a 0 until you press the button which will then return a 1.
You can use this in assignments to, such as:· temp = ~IN0·· or switches = ~INL
...and in compares, such as: IF ~IN0 = 1 THEN
I hope this helps.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering