


A while back a friend asked me if I could build a custom toy for a little guy called Oscar. She said something in the lines of ”The little guy is crazy about knobs, button, switches and blinking lights. You know, the same stuff that you like.” Of course I could not pass up an opportunity to lead a new requite towards the world of electronics so I accepted. Now it’s finished and the Color mix master is born.
Operation
The basic function is that the six RGB diodes on the top is controlled by the knobs, switches and buttons below. The color mix master has 5 modes which can be cycled between by pushing the buttons at the bottom.
Mode 1
In mode one the three switches works as a way to input a binary number. The LED that correspond to the number set by the switches is lit up correspondingly. The three knobs that are colored red, green and blue can be used to set the hue of the LED.
Mode 2
In mode two the three switches works as a way to input a binary number just as in mode one. But what is different in mode two is that the all LEDs up to the number that correspond to the number set by the switches are lit up. The three knobs can be used to set the hue of the LED.
Mode 3
In mode three the switches works just like in mode two but LED color is a fading rainbow and the knobs have no function.
Mode 4
In mode four the switches works just like in mode two. The LED color is a some random sparkles in different colors and the knobs have no function.
Mode 5
In mode five the switches works just like in mode two. The LED color is a dot moving back and fourth between left and right with a fading rainbow trail and the knobs have no function.
Hardware
The case of the color mix master is an old router that I have spray painted red. It had plenty of room inside after ripping out the old circuitry.
The LEDs are through hole APA106 LEDs and they function in all essence like the WS2812B that is sold by Adafruit under the name Neopixels. They have the nice ability that you can address each diode individually using only one output from the microcontroller. Each diode has a data in, data out, GND and 5V. The diodes are connected one after another where the output from one diode is the input for the next. To make the spacing between the LEDs match the holes I had drilled in the case I made a little jig with the same spacing between the holes as in the final case to use while soldering.
The microcontroller is an Pro Mini, it has the same Processor as the Arduino, ATmega328P, but it doesn’t have USB or a voltage regulator, this makes it bit cheaper but you have to take care of the usb communications and power control your self. To provide 5V power I used a standard LM7805 voltage regulator and a 9V battery. The LEDs shouldn’t be powered from the microcontroller directly because they consume quite a lot of power and you would risk damaging your microcontroller. Instead you can run power to the LEDs directly from the LM7805 as long as you remember to connect the ground to the same rail as the microcontroller is using. If you would like to build a similar device based on my code any microcontoller that can be programmed with the Arduino IDE can be used just as long as it has at least 6 Digital IO pins and 3 analog input pins.
Software
The software is a real hack. It was done in haste to be ready for christmas and can be improved greatly. I had problems to get the debouncing library to work so every time I pressed the button it registered as two presses. There are also unused methods etc. but hey it works! The LEDs are controlled by the excellent fastled.io library. The code is available at my github: https://github.com/clarholm/Color-Mix-master
Kommentera