Even though this is fundamentally identical to the potentiometer circuit, it feels a lot cooler. You can get the LED to increase and decrease in brightness just by waving your hand in front of it. Here's a terrible video by me of the circuit in action.
The other awesomely useful thing that I learned building this circuit was the map function. In short, this easily solves the problem that I faced in my potentiometer controlled multicolored LED side project in Day 3. In that one, the potentiometer read in an analog signal between 1-1023 and the LED pins read between 0 and 255 and so I had to invent an adjustment factor to move between the two. The map function does that for me. So in this case I could do the function
lightLevel=map(lightLevel, 0, 1023, 0, 255);
which is exactly the same map function as required in this circuit as well. Cool stuff that will definitely save me time in the future!
lightLevel=map(lightLevel, 0, 1023, 0, 255);
which is exactly the same map function as required in this circuit as well. Cool stuff that will definitely save me time in the future!
No comments:
Post a Comment