Light sensing LED

Thread Starter

Razor Concepts

Joined Oct 7, 2008
214
I am trying to have a LED sense light. The anode and cathode are connected to pins on a microcontroller.

Here is what is looping:

Set cathode pin to output
Turn cathode high and anode low (to charge internal capacitor in LED)
Wait 1 millisecond for capacitor to charge
Set cathode pin to input
Wait <<any amount of time, from 1ms to several seconds>>
Read values from ADC

No matter what, I get VCC (5v) as the output from the ADC, and I verified it with a multimeter. Any ideas on why this is happening?
 

HarveyH42

Joined Jul 22, 2007
426
I did this a while back as a test, but haven't gotten around to do anything more with it. Mine uses a red LED hooked up to the ADC pin on an ATtiny13, and I just read in the voltage the LED produces. It works similar to a solar yard light, turning on a blue LED. The BOD shuts it down when the batteries are drained, and restarts the program next day. Eventually, I'll get around to doing some flashing lights. With only 6 I/O pins, I didn't want to waste one on a dedicated sensor, and figured one LED could be dual purpose.

Read about the charging and waiting thing a while back, still don't see the point, unless it's like maybe low indoor lighting, and the LED doesn't produce enough current to detect by itself. The article was more for a switch (button) type application, where it detects whether the led was covered. So a little different from what I had in mind.
 

Thread Starter

Razor Concepts

Joined Oct 7, 2008
214
Thanks for the info. I was hoping to have the led detect how much light is reflected back when an object is placed over it, like this table:
RGB Table

It appears that the table uses the same principle, using the RGB leds to both sense what color object is above it, and to output the color of the object.
 
Top