3
\$\begingroup\$

For example I have a microcontroller running at 3.3v.

I want one GPIO pin to switch a 12v relay and a 5v load. Do I need to use multiple transistors? Or would something like this work?

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Your missing a resistor on the led. Even at 5V, it will likely blow. Unless it has a built in resistor or meant for 5V constant voltage. \$\endgroup\$
    – Passerby
    Nov 5, 2017 at 1:31
  • 1
    \$\begingroup\$ Yup, missed the resistor, though the LED was meant to be a placeholder for some load. Thanks \$\endgroup\$ Nov 5, 2017 at 4:02
  • \$\begingroup\$ And in most cases, you can power multiple mosfets in parallel from the same GPIO. Multiple transistors are difficult due to current limits on gpio. \$\endgroup\$
    – Passerby
    Nov 5, 2017 at 4:04
  • \$\begingroup\$ Why not have all voltages the same (12V) and bias the LED accordingly with a proper resistor, as well as the FET? 500 ohms shd do it for the LED. \$\endgroup\$ Nov 5, 2017 at 13:18
  • \$\begingroup\$ @Tim Those are just theoretical loads. I have 2 devices that are running on different voltages \$\endgroup\$ Nov 6, 2017 at 3:18

1 Answer 1

10
\$\begingroup\$

Yes, this will work if you change it slightly. Put a resistor and a diode (i.e. 1N4148) in series with the LED so it doesn't die from too much current or reverse voltage. Also put a free-wheeling diode across the relay to protect the transistor from voltage spikes.

schematic

simulate this circuit – Schematic created using CircuitLab

If your 5V load isn't a LED, you need at least the diode (D4) in series with it but not the resistor.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks. Is the diode required because the other load is a relay? \$\endgroup\$ Nov 5, 2017 at 1:21
  • 3
    \$\begingroup\$ No, it's because the 12V source would otherwise try to force current backwards through the series combination of the relay, the LED and the 5V source. \$\endgroup\$
    – Dave Tweed
    Nov 5, 2017 at 1:23
  • 2
    \$\begingroup\$ Assuming the relay coil, and the led blocking, this may be less of an issue than others suggest. Of course, you could simply power the LED from the 12V source instead, making this question moot. \$\endgroup\$
    – Passerby
    Nov 5, 2017 at 1:31
  • 1
    \$\begingroup\$ @Passerby Reverse biased 'blocking' LEDs will often die at < (12-5) = 7V reverse bias. \$\endgroup\$
    – Russell McMahon
    Nov 5, 2017 at 10:53

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.