Detecting Presence of LED

Hey all,

I've been playing around with my Due by connecting it up to openFrameworks and Unity. I'm looking to build something in Unity that requires me to know BOTH if a 5mm LED is being powered and if it is currently plugged into the arduino.

The first one is super simple - just requires keeping track of a boolean. The second one was easier than I expected, but I want to make sure that I am not going to fry anything. I have a minimal electronics background from working in an electrophysiology lab, but I'm finding myself a bit overwhelmed in trying to figure this out, so I'd love (and be super grateful for) any help - even if it is just pointing me in the direction of what I need to learn.

Here's the setup:

Power is taken from one of the digital pins. It is passed through a 200 ohm resistor which then is hooked up to both my LED and an analog in pin. The negative end of the LED is then wired up to the ground. If the LED is not present, the analog pin registers 1023. If the LED is present, it registers something lower. I then repeat this circuit a couple times, so that I can have three "traceable" positions where the LED can be placed.

I don't see any problem in that. The current-limiting resistor is key, of course. Otherwise, you would hit the analog pin with a 5v output, and I think something would likely get fried. 200 ohms gives you 25 mA at 5v, which is a bit more than the nominal 20 mA value that's given for your typical LED, but it's well below the 40 mA that a digital pin is capable of sourcing. If you were willing to tolerate a little less brightness on your LED, you could save some power and extend the LED's life at the same time by increasing the resistor to 220 or 270 Ohms.

Whew, thanks!

Also:

40 mA that a digital pin is capable of sourcing

Filed away as important knowledge!

For more information on that topic: Arduino Playground - ArduinoPinCurrentLimitations

Bear in mind that 40 mA per pin is the Absolute Maximum, and you would do well to give yourself a buffer below it for day-to-day use. Also, bear in mind that the Arduino's 5v rail and its individual pin-banks have their own current limitations that you may exceed, even while keeping individual pins below their Absolute Maximum.

For more information on that topic: Arduino Playground - HomePage

Fantastic - this will definitely help me get my bearing!

mikewesthad:
Whew, thanks!

Also:

40 mA that a digital pin is capable of sourcing

Filed away as important knowledge!

I'm not sure i should point out something i'm scared scary grumpy wumpy mikey wikey might post yhat the information i give is incorrect and then be a pompus twat about it..

But he's using a DUE the link is to an uno which is 5v input tolerant while the due is 3.2v

I am so very sorry from the top of my head if the due's voltage is a volt higher or lower, i do not wish to upset the important one if i'm wrong.