How to connect a button to a Teensy 3.2?

Status
Not open for further replies.
Hi everybody,

I am new to electronics so please forgive me for asking this basic question. I try to connect a button to Teensy and I do exactly what it says on this tutorial (https://www.pjrc.com/teensy/tutorial3.html), but I fail. I test the circuit by using the DigitalReadSerial example on Arduino, and it shows 1 when I don't touch the button, shows off-line when I touch it. However, what's supposed to show is 0 when I didn't touch it because the code is used to tell the button state.

I am using a normal breadboard button. The input pin is 19.
 
We could probably help figure out where things went wrong, if only we could actually see what you did. Maybe share photos?
 
example.jpgWX20190323-221726@2x.jpg Here is the code and my circuit. I attached teensy 3.2 to a "SmartMatrix products" but you can ignore the shield on the back and all these yellow and orange wires are connected to an SD card.
 
With Teensy 3.2 - safer to use 3.3V than 5V

That tutorial is for 5V Teensy 2's unfortunately. Though shown there is running the source power through a resistor not shown in the pictures ?

That likely doesn't relate to the issue.

Also that button has room for two unique connects? 3 are shown: { 5V, GND, pin 19 } - which seems wrong as closing the switch will put 5v to GND?

Test the connects on the button - some connect side to side and some diagonally. As connected 5V may be on the open switch and it is dropping to 0:Low when closing and shorting 5V to GND without a visible resistor to limit current flow?

Would be better to just have:
pinmode( 19, input_pullup );

Then connect one side of button to GND and the other to pin 19.

This would by design show a 1:High when the switch is open and then drop to 0:Low when the switch closes.

This may not be the best - it still shows 5V not 3.3V in use - but is the first I clicked and it has a section :: Using the Arduino integrated resistor to PullUp
It has example code - does not require running power to the switch - just Pin 19 connect and GND - and will reliably give a 1:High when the switch is OPEN and drop to 0:Low when the button is pressed closing the switch.

Also note that simple buttons will typically bounce high and low multiple times when the switch is changed. This PJRC page shows code - but not wiring like above to deal with that Bounce - and give sample code like above with INPUT_PULLUP in use.
 
Remove the red wire (you only need 2 wires - having this 3rd wire incorrectly connected is causing the problems) and change INPUT to INPUT_PULLUP.
 
Status
Not open for further replies.
Back
Top