using DigitalIn to drive an LED ?

17 Jun 2011

Hi all..

ok, bit of a weird request, I have set a pin to digitalIn, and connected an LED between it and 3v3. I was expecting the LED to light. I was presuming the DigitalIn would sink the 20mA or so needed to light the LED ?

I want to be able to tell when the LED has been removed, which is why I'm doing it like this.

Bizarrely, although I can sense when the LED is there, and when its not. It doesn't light up.

Can anyone enlighten me ?

cheers,

Dave

17 Jun 2011

Inputs don't typically sink or source any significant current. The inputs can be configured in software to have a pull up or pulldown resistance but this is on the order of 10K ohms. Even if a pulldown resistor was enabled it will only sink about .1 mA.

If you want the LED to light up you need to provide a pulldown resistor, something around 220 to 470 ohms.

17 Jun 2011

Many thanks. So I connect the led to 3v3, and connect the other end to a pull down and the digital in. That will make the digital in high and the led will light. When I remove the led, the digitalin goes low.

Smashing.

Thanks again for the reply.