The SuperBlink sketch allowed us to create a number of LED animations/transitions. But it is only a matter of time before you opt for something more interactive. In this tutorial, we will make use of a photo resistor (or light dependent resistor : LDR) to create an exciting LED display.
Photo resistors are variable resistors which change resistance depending on the amount of light hitting the sensor. When you move your hand closer to the sensor, you tend to block an increasing amount of light, which increases the resistance of the photo resistor. As you move your hand away, the amount of light hitting the surface of the photo resistor increases, thus decreasing the resistance.
The change in the resistance of the LDR, will affect the voltage being read at one of the Arduino's Analog Input pins (A0). As resistance increases, the voltage drops (and vice versa).
V = IR
V = Voltage, I = Current, R = Resistance
The voltage reading will be used to select which LED to turn on
Fritzing Sketch
If you liked this tutorial - please support me here: Photo resistors are variable resistors which change resistance depending on the amount of light hitting the sensor. When you move your hand closer to the sensor, you tend to block an increasing amount of light, which increases the resistance of the photo resistor. As you move your hand away, the amount of light hitting the surface of the photo resistor increases, thus decreasing the resistance.
The change in the resistance of the LDR, will affect the voltage being read at one of the Arduino's Analog Input pins (A0). As resistance increases, the voltage drops (and vice versa).
V = IR
V = Voltage, I = Current, R = Resistance
The voltage reading will be used to select which LED to turn on
The Video
We now have the power to control which LED we want to light up. This would look very nice with different coloured LEDs, but unfortunately I am stuck with the Yellow and Red ones from the Sparkfun Inventor's Kit.
Fritzing Sketch
Image created using Fritzing : http://fritzing.com
Arduino Code
1 | /* ======================================================== |
No comments:
Post a Comment