Electrical – How to ensure an LED is completely off when pin is set LOW

arduinoled

I have a situation where, when the associated pin is set LOW, the LED still glows faintly. As this is to be used in a darkened area, it is quite noticeable.

So far, I have encountered this only with one of my Arduino boards, and only when the LED colour in use is pink, as opposed to yellow or blue, which are the only other colours I have tried. Increasing the resistor from pin to LED to 1K ohm does not resolve the issue. Also, the use of a different pink LED does not affect the outcome.

I realize that setting a pin "LOW" does not imply zero current, so how should I handle this problem? Though I am quite familiar with the Arduino, my knowledge of Electronics in general is quite shallow, and ask that any response take this into consideration.

Best Answer

The LED should extinguish completely. You must have a wiring error or are not driving it correctly in the software.

One possibility is that you have the pull-up enabled in the processor.

The AVR microprocessor has the ability to enable a high-value pull-up resistor (20k) if needed. If you do this when you intend to turn the LED off it will glow dimly.

One way this can happen is to set the pin_mode() as INPUT_PULLUP. It will also happen if you turn the pin to an input and write a 1 to the pin output register.

The usual way to connect an LED to an Arduino or other processor is to connect one end of the LED to the +5V with the other end connected to the output pin through a resistor in the range of 220-1000 ohm depending upon the LED and brightness required.

Some people call this resistor a current-limiting resistor, I prefer to call it a current defining resistor. It is not there to protect the LED it is to set the desired current.

You write 0 to the pin to turn the LED on and a 1 to turn it off.