Silly question time: push button

Status
Not open for further replies.

wurls80

Member
Ok. This is a simple question but I can't get my head round it at the moment, so please excuse my stupidity.
I have a power supply providing 5v to an enclosure. Within the enclosure the 5v supply powers a teensy board and a strip of addressable leds. The teensy board is the controller for the leds.
I want to add a push button for teensy to sense. It will then use the input to change what the lights are doing.
So I added the button and connected it as a pull down - so 5v on the digital pin being sensed and one leg of the switch, and the other leg connected to ground.
I've used the 5v directly from the supply.
Is this right? If it is, why doesn't pressing the button short out the supply to the teensy and the leds?
Should I be using the 3.3v supply from the teensy instead for the button? (Using a teensy 3.5, so it doesn't produce a 5v supply, but all pins are 5v tolerant).

Thanks in advance.
 
No. And you'll kill most Teensys if connect pins to 5V. They are not 5V tolerant. (T3.5 is)
Use pinMode(input, PULLUP); in your program. You can measure ~3 Volt on the pin then. That's due to a resistor in the teensy which is turned on with "PULLUP".
Connect the pin with the switch on side, gnd to the other.
 
Thanks Frank B.
Board is a 3.5 so I am 5v tolerant as you say.
I have physical resistor between the 5v supply and the pin. Sorry I hadn't mentioned that (trying to keep it simple - think I should be drawn a diagram!)
So I have 5v to resistor, the other side of which is connected to my input pin. Then one leg of my button is connected to my input pin, and the other leg to ground.
Based on what you've said Frank b I'm not sure that is right? But it is what I've seen in arduino examples.
As the ground is the negative of my 5v supply into the enclosure, won't pushing the button (and pulling the input to ground) also short out the power supply to everything in the enclosure?
 
Sorry Frank b I misunderstood what you meant. If I use the software internal pull up resistor then I need only connect the button to ground and the input pin, as the internal pull up resistor does the connection the Vcc.

Think I'll do that and stop worrying about it. The pull up resistor obviously stops the short by being a load when the button is pressed. Guess it's resistance needs to be suitably high compared to the other things on the supply that it doesn't divert current away from them.

Thanks for the advice, much appreciated
 
Status
Not open for further replies.
Back
Top