Mike - K8LH
Well-Known Member
Just started experimenting with the bi-directional properties of LEDs hoping to figure out a way to use an LED as both a push button switch and as an indicator. Also wanted to see if I could use an inexpensive LED as a replacement for an LDR in a clock project to detect ambient light level.
My first experiment accidentally produced a simple and fascinating Ambient Light Sensor and Display. I'm using a 16F690 with serial port module and a single red LED with anode connected to RA0 and cathode connected to RA1.
Basically I light the LED for 50 usecs then I reverse bias the LED to place a capacitive charge on the LED junction. Then I set RA1 (cathode) to input while leaving RA0 (anode) at ground and I increment a counter at 1 msec intervals while testing for a change of state from '1' to '0' as the capacitive LED junction discharges. I run the discharge time value through a 16 step FIR filter to smooth the results and then I print the discharge time of 000 to 255 msecs to Hyperterminal.
The results are stunning. The LED starts to flicker at around 40 msecs discharge rate (a moderately lit room) and slows all the way down to about 3 Hz in a dark room (discharge time >200 msecs). Well lighted rooms or sunlit rooms yield discharge times of anywhere from 10 to 30 msecs so the LED appears to be solidly lit. Shining a flashlight into the LED lens at very close range can get the discharge time down to 0-1 msecs. Putting your finger on the LED or casting a shadow on the LED will make the discharge time rise dramatically.
Anyone should be able to duplicate this experiment. Please let me know if anyone wants to see my code and/or schematic and I'll post it after cleaning it up.
Mike
My first experiment accidentally produced a simple and fascinating Ambient Light Sensor and Display. I'm using a 16F690 with serial port module and a single red LED with anode connected to RA0 and cathode connected to RA1.
Basically I light the LED for 50 usecs then I reverse bias the LED to place a capacitive charge on the LED junction. Then I set RA1 (cathode) to input while leaving RA0 (anode) at ground and I increment a counter at 1 msec intervals while testing for a change of state from '1' to '0' as the capacitive LED junction discharges. I run the discharge time value through a 16 step FIR filter to smooth the results and then I print the discharge time of 000 to 255 msecs to Hyperterminal.
The results are stunning. The LED starts to flicker at around 40 msecs discharge rate (a moderately lit room) and slows all the way down to about 3 Hz in a dark room (discharge time >200 msecs). Well lighted rooms or sunlit rooms yield discharge times of anywhere from 10 to 30 msecs so the LED appears to be solidly lit. Shining a flashlight into the LED lens at very close range can get the discharge time down to 0-1 msecs. Putting your finger on the LED or casting a shadow on the LED will make the discharge time rise dramatically.
Anyone should be able to duplicate this experiment. Please let me know if anyone wants to see my code and/or schematic and I'll post it after cleaning it up.
Mike