Red diode as light sensor for arduino - Page 1
Forum section: electronics / general

author: kalel
author_rank: Frequent Contributor
timestamp: June 18, 2017, 11:11:40 am
content: I experimented putting a 5 mm diffused orange, and a 3 mm red LED into the analog input to see whether or not these can be used to detect light on/off.Taking 3 samples with 150 ms in between and averaging them gave me the following values:Orange:- Around 200 when room light off, ~290 when battery flashlight directly shines, and around 230 with lights onRed:- Around 270-300 with room lights onI might want to try a UV LED as well.While there's not a drastic difference (e.g. 100 vs 1000) so mistakes can be made in detection, it seems that a simple diode might be usable to detect simple night conditions, e.g. to turn a nightlight on.As obviously I haven't done much experimentation yet, I would like to hear some opinions whether LEDs are usable for this function. Obviously there's no specific need, although they might be a tiny bit cheaper than photo sensitive resistors and diodes specifically designed for that, but there's no reason not to explore the possibility.

author: ZeTeX
author_rank: Frequent Contributor
timestamp: June 18, 2017, 06:15:05 pm
content: I might be wrong but LED's can't detect all kind of lights, some light from specific lamps won't work. (Again, I'm not sure about this at all).

author: kalel
author_rank: Frequent Contributor
timestamp: June 18, 2017, 06:21:04 pm
content: Quote from: ZeTeX on June 18, 2017, 06:15:05 pmThe RED LED is definitely going to filter some frequencies of light through the resin. So, probably clear resins work best. I don't have the facility to test multiple kinds of light sources, unfortunately. I actually expect even better results form the UV ones, and they also have a clear coating unlike the 3 mm RED ones. Of course, photoresistor/diode will likely both give much better results.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 18, 2017, 06:31:44 pm
content: It is known that LEDs also work as a detector. Usually they can only detect light with the same or shorter wavelength than they emit. So the UV LED would be sensitive to UV light only. The red LED should be sensitive to the light from the orange LED, but not the other way a round. Depending on the colors there might be a small overlap.Depending on the design of the LED, it is also possible that the LED will not be very sensitive for shorter wavelength light. This is because some LEDs (especially the efficient ones) us different band-gap materials, with the smallest band-gap only in the active zone. Thus shorter wavelength light is also absorbed in areas where it might be less effective. The colored plastic can have a similar effect.

author: jaromir
author_rank: Unknown
timestamp: June 18, 2017, 06:57:19 pm
content: Photodiodes (or LEDs used as photodiodes) also exhibit different behaviour depending on whether they are used in photovoltaic (open circuit, measuring voltage) or photoconductive (diode is short circuited, measuring current).The photoconductive mode is very linear; the current is proportional to incoming light in many orders of magnitude.Photovoltaic mode is non-linear (as you observed) and slower to response (probably not that important here).If you want to play a bit more, you may also try to use small diodes in glass package, like 1N4148 - some of them could be light sensitive. Also, if you happen to have metal-can transistor, you can open it and use the exposed semiconductor as photodiode.All classic PN junctions are photosensitive, sometimes causing problems. This thing happened to first batches of Raspberry Pi 3 (or 2?) - flashing light could reset it, as the photo-induced voltage disturbed internal circuitry, being in slightly translucent package.Also, I've heard of cheap multimeters in yellow plastic enclosure, being a bit translucent. There was COB IC inside, probably equivalent of venerable ICL7106. The black asphalt snort is opaque enough, but the thin PCB on bottom side isn't, so direct sunlight could penetrate both enclosure and PCB, offseting the measured voltage. Black marker or insulation tape on bottom of the PCB did workaround the problem.

author: tronde
author_rank: Frequent Contributor
timestamp: June 18, 2017, 06:58:21 pm
content: You have several analogue inputs on the Arduino. Try to read LEDs with different colours at the same time. You can use this as a "poor mans" colour detector.

author: kalel
author_rank: Frequent Contributor
timestamp: June 18, 2017, 07:01:41 pm
content: Quote from: tronde on June 18, 2017, 06:58:21 pmInteresting idea

author: cdev
author_rank: Super Contributor
timestamp: June 18, 2017, 07:54:41 pm
content: Here is an interesting hack. Clear plastic, relatively thick tubing internally reflects light - and the more it bends, the less light makes it to the other end. its been awhile since I saw the description of how this is done so this is from memory but basically you can make a bend sensor using two LEDs, one transmitting light and the other receiving, at opposite ends of a short length of clear plastic tubing. The amount of granularity/accuracy that this supports is fairly high, people have used this technique in homemade VR - for example, to make a data glove. (pro quality bend sensors use fiber optics in the same way)Ive never done this myself.

author: floobydust
author_rank: Super Contributor
timestamp: June 18, 2017, 11:43:19 pm
content: The photo-current is extremely low, so don't forget a capacitor like 0.1uF to store charge for the Arduino's A/D input capacitance.Be careful what light source you are using- light bulbs LED CCFL etc. many sources are actually flickering so I would average the A/D reading longer than a mains cycle.

author: Brumby
author_rank: Unknown
timestamp: June 18, 2017, 11:51:46 pm
content: I had a play with this idea a few years ago with some LEDs I had lying around. Testing was simply using my multimeter - not an Arduino.I found my red ones to be the worst, with yellow the best and green not too far behind.Not sure of the specific technology used, but I'd had them for a while.

author: kalel
author_rank: Frequent Contributor
timestamp: June 19, 2017, 12:38:43 pm
content: Quote from: Kleinstein on June 18, 2017, 06:31:44 pmI apologize, twice I mentioned UV by mistake, but I actually meant quite the opposite - IR. I don't have any UV LEDs to test with.IR LEDs should have a good sensitivity comparing to others (based on some previous multimeter testing). I think I received more voltage from them than the red LEDs with LED flashlights for light source. I find it easier and more fun to test on the Arduino however, because I can trigger some action based on input value (so, it can even serve a logic purpose potentially).Also, a lot of interesting suggestions here, thanks for them.