Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Silly question time: push button

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    17

    Silly question time: push button

    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.

  2. #2
    Junior Member
    Join Date
    Oct 2018
    Posts
    17
    Ps No, I haven't powered it up and tried it yet

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,774
    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.

  4. #4
    Junior Member
    Join Date
    Oct 2018
    Posts
    17
    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?

  5. #5
    Junior Member
    Join Date
    Oct 2018
    Posts
    17
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •