I have a microcontroller (teensy 2.0++) that is powered and communicated to by my computer via USB.

I have a small board that has a 3V coin cell and a push button that you can press and LED goes on.

I have used a voltmeter to check find that one side of the push button is ground, and also that when you press the button the two different sides of the push button go from not-connected to connected.

I would like to use GPIOs from my microcontroller to "push" the button somehow

I will solder male dupont connectors to the two different sides of the push button. I can connect these to ground, and GPIOs and build whatever circuit is required on a breadboard.

How can I design a circuit that will let a GPIO pin from my microcontroller 'bridge' the two terminals of the push button?

The aspects of this that I am unsure about are the fact that I have two separate power sources involved. It doesn't look like I can easily remove the coin cell and power the button board from USB. I also am sure that I cannot power the secondary board from a GPIO pin, as that may pull too much current and damage that GPIO pin. I think that I should be connecting my microcrontroller's ground to the ground of the button board. I have been thinking that pull-up and pull-down resistors may be useful in designing a circuit for this. I am also wondering if a transistor is required.

To help make it easier to answer this question. I've made a rough diagram of the pins I think are relevant to this, my problem is what to put in the middle.

enter image description here

  • 1
    \$\begingroup\$ Share the grounds only and use a transistor. \$\endgroup\$ Commented Dec 25, 2023 at 14:11
  • \$\begingroup\$ Does the small board have only a 3 V coin cell, a switch, and an LED, or is there some other circuitry? What colour is the LED? \$\endgroup\$ Commented Dec 25, 2023 at 16:54

3 Answers 3


Because one of the power sources is a battery, having two different power sources is not a problem. The entire battery circuit is "floating" with respect to the uC's GND, so as long as there are no other powered components /modules/assemblies in the system, you can connect the battery circuit GND to the uC GND.

You might be able to pull the switch contact to GND directly with a GPIO pin that is configured as open-drain, but I'd have to know more about the teensy output stage before recommending that.

You can pull the switch contact to GND with a small-signal NPN transistor such as a 2N4401, 2N3904, 2N2222, or a small MOSFET such as a 2N7000, or 2N7002 if you are working in surface mount.


Gate - GPIO pin

Source - GND

Drain - Switch contact


Base - resistor - GPIO pin

Emitter - GND

Collector - Switch contact

With the NPN transistor, you need a series resistor to limit the current through the base. Anything in the 10 K range will work. No gate resistor is needed with the FET.

To be clear, configure the GPIO pin as a totem-pole output. In this way, you do not need any pull-up or pull-down resistors.

Here is a schematic.

enter image description here

  • \$\begingroup\$ UPDATE: Added schematics. \$\endgroup\$
    – AnalogKid
    Commented Dec 25, 2023 at 16:28
  • \$\begingroup\$ Thank you so much. I have BC557 BC547B, do you think either of those would be ok? I have looked at their data sheets and that of the 2N4401 but I am not sure how to decide if they are appropriate or not. \$\endgroup\$ Commented Dec 25, 2023 at 18:46
  • \$\begingroup\$ The BC557 is a PNP transistor, and will not do what you want in this circuit. The BC547 is an NPN transistor, and should work well. \$\endgroup\$
    – AnalogKid
    Commented Dec 25, 2023 at 19:43

In theory, you can use Teensy outputs to simulate a push button, if the button just pulls a pin to ground.

But if the other circuit uses a battery, if you unpower the Teensy, it will likely look like the button is pushed all the time.

That is not a problem if you power the other circuit from Teensy instead of battery.

If you want to keep power supplies separate, use a BJT or FET transistor.


While the transistor-based solutions are fine and cheap, I personally would use reed relay. This is worry-free option that allows interfacing with any device that has buttons, regardless of power supply or operating voltages. It will even emulate the contact bounce of the button :P

Look for low coil current and built-in diode. Something like SIL03-1A72-71D.


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.