3
\$\begingroup\$

I'm trying to make a semaphore using to LEDs green and red, controlled by one arduino pin. Idea is when pin is low red LED is on and green LED is off, when pin is up green LED is on and red LED is off.

So I've made the circuit using two transistors and in simulation software everything seems to be ok, but on practice red LED (right one on the picture) is still shining dimly when the green one (left one) is on.

On diagrams you can see there is still a small current through red LED, when the pin is in up state.

Is there any ideas how to deal with this current?

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Hmm. Is 33 uA too high to call the LED "off"? \$\endgroup\$
    – Greg d'Eon
    Commented Apr 14, 2015 at 13:08
  • 2
    \$\begingroup\$ Yes, I real circuit the LED is still shining, but dimly \$\endgroup\$
    – Stepan
    Commented Apr 14, 2015 at 13:14
  • \$\begingroup\$ Similar question: electronics.stackexchange.com/questions/106090/… \$\endgroup\$
    – Cano64
    Commented Apr 14, 2015 at 16:21

4 Answers 4

2
\$\begingroup\$

Two words - source, sink.

The output pin of an arduino is capable of sourcing (supplying an output current) as well as sinking (taking a current into the output and down to ground.) see http://arduino.cc/en/Tutorial/DigitalPins

You don't need any transistors to switch the LEDs.

enter image description here

In this circuit when the output is LOW (near 0V) the green LED will be ON, red is OFF. When the output is HIGH (near 5V) the red LED is ON , green is OFF.

The resistors limit the sink/source current to a safe value.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Same as @MichaelKaras - both LEDs will be partially ON if the drive pin is hi-z. \$\endgroup\$
    – Dzarda
    Commented Apr 14, 2015 at 13:56
  • 1
    \$\begingroup\$ @Dzarda To quote from the reference given in the answer about configuring the pin as an OUTPUT "Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits." - Not exactly High z! \$\endgroup\$ Commented Apr 14, 2015 at 14:19
2
\$\begingroup\$

For the sake of completeness: If you wanted to provide more current than your MCU can deliver, you can still use two transistors, but this time one NPN and one PNP. NPN in this case works as a non-inverting switch, PNP is inverting.

Note: This only works if your Drive voltage (MCU pin) goes all the way from 0 to 5V. Not a problem with the ATMega.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
1
\$\begingroup\$

Looks like you have voltage leaking from the 5V through the second transistor base to the emittor, which is giving you a faint glow (Similar to the problem I faced in this post). As the current from the Arduino is enough to power 1 LED at a time (with a ~300-470Ohm resistor), you could just use the circuit from my post to make this all work. Saves you a transistor :)

EDIT: The full circuit you should implement (your Arduino pin goes where IN1 is, and you should replace the 9V source with your 5V source or with another pin from the arduino) is this (from this post):

schematic

simulate this circuit – Schematic created using CircuitLab

NOTE that this assumes LED1 is Red and LED2 is green - so you would have to invert your pin logic on the Arduino.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ LED2 will always be on in this circuit (assuming same forward voltage) \$\endgroup\$ Commented Apr 14, 2015 at 13:16
  • \$\begingroup\$ Thank you, I forget about difference of voltage of LEDs. This circuit is working fine, but another with source / sink work properly without any transistors! \$\endgroup\$
    – Stepan
    Commented Apr 14, 2015 at 14:37
  • \$\begingroup\$ @geometrikal That's why my NOTE says "LED1 is Red and LED2 is green" - as per the linked post the reversed scenario indeed keeps LED2 always on \$\endgroup\$
    – Phil B.
    Commented Apr 14, 2015 at 14:51
  • \$\begingroup\$ @PhilB. Colour of the LED doesn't necessarily correspond to forward voltage. \$\endgroup\$ Commented Apr 15, 2015 at 5:53
1
\$\begingroup\$

A good way to deal with this is to stop putting the LEDs in to the emitter part of the circuit. Instead put the LED's in the collector part of the circuit in series with the current limit resistors.

Another thing to consider is that if the MCU pin has adequate drive capability and a 5V voltage swing you may consider simply connecting up the LEDs as follows:

enter image description here

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Note that if the MCU PIN is tri-stated, both LEDs will shine at lower intensity. \$\endgroup\$
    – Dzarda
    Commented Apr 14, 2015 at 13:53
  • \$\begingroup\$ Should not be a problem for the OP as they said that the MCU pin would be High or Low. The MCU pin in INPUT mode would result in the condition you specify and would exist from MCU power on and until the software sets the pin of output. The both on dim indicator can mean the software is not running properly. \$\endgroup\$ Commented Apr 14, 2015 at 14:01

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.