3
\$\begingroup\$

I have ESP32 with one pin with 3.3 V High level and 0 V low level. I want to control red and green led from this pin:

  • I want to power leds from 12 V power source.
  • The red led is 2 V 20 mA, green is 3 V, 20 mA.
  • I want to lit red led if pin is low (0 V), green is off and the red is off and green lit when pin is High.

I can use NPN transistor to lit green when is Hi and turn off when pin is low, but I don't know how to lit red when pin is low and turn off when pin is Hi.

\$\endgroup\$
3
  • \$\begingroup\$ One Led should be active Low, another should be active HIGH. \$\endgroup\$ Commented Dec 14, 2024 at 18:56
  • \$\begingroup\$ Is it possible to interchange the LEDs? If so, the problem could be solved using a single NPN transistor. \$\endgroup\$ Commented Dec 17, 2024 at 20:40
  • \$\begingroup\$ Yes it is possible! I need one red and one green LED with same size! \$\endgroup\$ Commented Dec 19, 2024 at 5:39

1 Answer 1

1
\$\begingroup\$

Here is one way to do it. When the input is low, the MOSFET gate is high and the green LED D2 is 'on' and the red LED D1 is 'off'. When the input is high the BJT is 'on' pulling the MOSFET gate low and turning the green LED 'off' and the red LED 'on'

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • \$\begingroup\$ Thank you! I will test it. Can I make it with two transistors NPN or NPN and PNP? \$\endgroup\$ Commented Dec 14, 2024 at 21:34
  • \$\begingroup\$ Not directly, the circuit depends on the MOSFET gate drawing almost no current to keep D1 from lighting. You could use a Darlington NPN+NPN in place of M2, add a 1MΩ base resistor and shunt D1 with 50kΩ and it should work. \$\endgroup\$ Commented Dec 14, 2024 at 21:54
  • 1
    \$\begingroup\$ Thank you very much! \$\endgroup\$ Commented Dec 15, 2024 at 7:58

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.