Tuesday, October 13, 2009

photocell + LED array

I'm highly enjoying playing around with the led array created in the last post. New images and videos at the end of the post.

It's quite simple. 7 LED's on a protoboard, that create a visual bar graph of 0 - 100%

running a sketch [link @arduino.cc] that takes an analog input, and 'maps' out a value of zero to one-hundrend.
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);

where ledCount is a variable that defines how many led's are on the board (in my case, 7)
last post i hooked up a potentiometer to the analog input. A reading of zero volts, and no LED's would illuminate. However, at 30% power (1.5v) then two LED's light up. and at 100% power (5v) all the lights illuminate.

In this post i hookup a photocell diode (photo resistor,) which depending on how much ambient light is present will add or decrease the resistance of the 5v being sent through it. (same principle as the potentiometer, except no manual parts, its resistance value is purely light dependent.)

Picture :

1.) 6 out of 7 LED's illuminate when exposed directly to a desk lamp.

2.) When my hand is blocking part of the light, then one of the LED's turns off, now illuminating just 5 out of 7.

3.) Now blocking all of the direct light from the lamp, another light turns off. The only light exposed to it now is ambient light, which is still picked up by the photocell and illuminated 4 out of 7 LED's. If i put a blanket on it, all lights would turn off.


No comments:

Post a Comment