I built a mood light using an Arduino Nano and an RGB LED, diffused through a ping pong ball. The mood light is controlled using a push button and two potentiometers. The mood light has two modes: one in which you can set the color of the light, and another in which the RGB LED will automatically cycle through the hues of the HSV color spectrum. The push button changes between modes, and the potentiometer on the left changes the brightness of the light in both modes. In the "Set Color" mode, the potentiometer on the right changes the hue of the light, and in the "Cycle" mode, the potentiometer on the right changes the rate at which the colors cycle.
Click "Read More" below for details about my build process.
This idea for this project was inspired by Elco Jacob's ShiftPWM library, though his library is not actually used in my mood light. After building the schematic on his page for myself, I decided I really liked the "rainbow" visual effect that the RGB LEDs make and wanted to recreate that with one RGB LED.
I began writing the code for this project. Because I was limited to two potentiometers, I wanted a way to control brightness with one pot, while being able to control color with another pot. After doing some research, I discovered one way of doing this would be by using the Arduino to convert HSV color values into RGB color values, using the RGBConverter library. With this library, I was able to use one pot to change the "V" value, or brightness, and the other pot to change the "H" value, or hue. Saturation remains the same throughout the entire code.
Coding the "cycle" mode introduced the concept of using the millis() function as a delay. I needed the Arduino to constantly check for button presses, while having a delay to determine how fast the colors on the LED would change. The millis() function paired with a while loop allowed me to do just that.
Breadboard Prototype |
One of my goals for this project was to make a more polished enclosure, as my last project had me using a soldering iron to make holes. I had access to a drill for this project, as well as a dedicated electronic enclosure and a stripboard to make soldering connections. I used hot glue to secure and mount the RGB LED and the ping pong ball onto the enclosure.
Bottom of the stripboard |
Mounted potentiometers and push button |
Internals of the finished mood light |
No comments:
Post a Comment