2

I'm building a project on mi Pi 3 and I was wondering if it's possible to simulate a button press.

What I mean is, I have a control board for a screen, that has buttons: volume up, down, power, etc.

What would happen if I desolder the button, and proceed to solder ground to one end and v+ to the other one (3.3 logic), and set the GPIO pin to high?

Would that simulate a button press?

3
  • 4
    No one can say unless you explain the circuit the button connects to.
    – Milliways
    Dec 17, 2016 at 6:49
  • 2
    Why simulate a button instead of just hook up a button? Dec 17, 2016 at 7:04
  • 2
    When I want to simulate an input I just set the GPIO high or low externally to the program. That simple approach will probably work for 90+% of Pi applications.
    – joan
    Dec 17, 2016 at 8:58

1 Answer 1

1

if i desolder the button, and proceed to solder ground to one end and v+ to the other one (3.3 logic) and set the gpio pin to high would that simulate a button press?

If you want to use the GPIOs directly and you are sure the button uses 3.3V logic, make sure there is a common ground between the device and the Pi, then you only have to deal with the button's input (one connection). The other one can be left disconnected.

You need to determine which one is the input and whether that input is active high, in which case it sinks current, or active low, in which case it is a source. This may be a problem, because either way there will be a positive and negative terminal when tested.

However, you can try it both ways with the same setup. You want a decent size resistor in between, a few kΩ +.

If the button input is active high, then the GPIO should be set low and when driven high will emulate a click. If the button is active low (i.e., a press is when the input is sent to ground), then the GPIO should be set high and driven low to emulate a click.

As long as the resistor is there, you have a common ground, and the buttons are 3.3V logic, you can test both possibilities with both leads safely, and once you have it straight, leave the other side disconnected.

3
  • Why is the resistor required? Should it be in series between GPIO and the input or should it be in parallel between GPIO and ground? Aug 22, 2022 at 18:07
  • It depends on how much current what it's attached to sinks or sources, and whether there is a resistor inline there already. The GPIOs do not have a very high tolerance for current, somewhere around 20-25 mA, so you want to make sure this is limited.
    – goldilocks
    Aug 22, 2022 at 19:41
  • OK thank you. I did it without and it works, so I guess (hope) that there may already be one in the button I'm controlling. Aug 23, 2022 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.