Well today is Saturday so that means more Micro Controller FUN TIME!
Today we will be playing with my RGB LED and using various sensors to control the color.
Lets first start just with the RGB LED. I've written a simple for loop that loops through each color separately once, while the other colors are set off. The color simply gets brighter as the value sent to the LED varies from 0 to 255. Then I use the same scale but increase RED from 0-255, decrease GREEN from 255 to 0 and leave BLUE set to 255. Lastly I set RED to 255, increase GREEN from 0-255 and decrease BLUE from 255 to 0. All this takes is 5 simple for loops. Simple.
Next is a quick video showing the use of the soft potentiometer. As you can see as I move my finger along the softpot, the color of the LED changes! HORRAY!!!
After that I thought, well lets see if we can use the temperature to control the light color. Using the map function I was able to get this work quite well, at least I think so. Here it goes from blue when less than 18 Celsius degrees to red when more than 25 degrees Celsius. I could have just as easily mapped this to be very sensitive to small changes in color. Or even a easier, a threshold value, but I wanted to do a gradient.
No comments:
Post a Comment