This weekend, I decided I wanted to take an RGB LED strip controller that I'd been working on and make it a little more permanent. I took everything off of my breadboard and added it to a proto shield that I had, and I'm pretty happy with the results. I plan on bringing it back to school with me in the fall and using it to control lights in my room.
a basic outline of what I used for a circuit |
I'm controlling a 5050 LED strip with my circuit. This type of strip contains red, blue, and green LEDs in each of its modules, so I'm able to change its colors by varying how much each LED is turned on. The strip is controlled through four pins; a positive rail and a ground for each color. I've made it so that I can control the colors of the strip using pulse-width modulation from three digital PWM pins on an Arduino Uno.
The three n-channel transistors shown in the circuit act as switches that I control through the Arduino, allowing me to turn the red, green, and blue LEDs in the strip on or off. When I send a high signal to the base of one of the transistors, I allow for current to flow through its other two pins, effectively turning on one color in the LED strip. On the power supply side of things, the 5 volt regulator and capacitors allow me to create a smooth 5 volt signal from the 12 volt power supply that came with my strip. This way I can run both the Arduino and the strip with the same supply.
Since my Arduino is 8-bit, I'm able to vary each color by 256 increments of brightness. In order to produce colors other than red, green, and blue, I turn on each of the three colors at different values between 0 and 255. So in other words, I can produce a lot of colors. In order to clear things up a bit, here's an example of how this would work. Say I want to produce white light. In order to do so, I would set the values for my red, green, and blue outputs all equal. For a dim light I would set them to low values, such as 50. For maximum brightness, I'd set them all equal to 255. It's that simple.
So far I've been using example code from Adafruit to control my strip, but I'm in the process of writing my own code that will allow the strip's colors and brightness to be controlled by music. This is why there's an audio adapter in my schematic.
I'll be doing another writeup on my code for music synchronization sometime in the near future, so stay tuned!
No comments:
Post a Comment