The LED is commonly used as an OUTPUT device, however, I have since found out: there is another option.
You can use the LED as an INPUT device !!
I have only tried this with a Yellow LED and a Red LED, however, this should work with any colour. Some sites recommend using a clear/transparent/colourless LED for best effect, but it depends on what you are trying to achieve.
The LED responds better to light of the same wavelength that it emits. So a yellow LED responds better to yellow light, and a red LED responds better to Red light.
The following experiment attempts to prove this theory.
A Red and Yellow LED alternate and fade in to maximum brightness using PWM (Analog Output). Meanwhile, a separate LED is used as an INPUT device to receive the light. The value obtained is plotted using a processing sketch.
The chart above used a Yellow LED to measure the light emitted from a Red and then a Yellow LED.
As the Yellow LED gets brighter, the INPUT LED takes less time to discharge, and thus produces a lower result. On the other hand, the Red LED has little effect on the INPUT LED, despite it's brightness.
Ambient light will produce different graph patterns.
- Arduino UNO
- 2 x Yellow LEDs
- 1 x Red LED
- 3 x 330 ohm Resistors (choose resistors suitable for your LEDs)
- 5 wires to connect the circuit
- Processing software
Created with Fritzing : http://fritzing.org/
Here is the Arduino Code: which was adapted from this site.
Here is the Processing Code: Code Source