The other day I was walking around Ikea for some reason or another and I noticed this cool LED thing called the Dioder. It consists of 4 strips of 9 bright RGB LEDs (a.k.a. pretty color changing lights) with a control box and a bunch of cabling allowing you to arrange the LED strips in many different configurations. The Dioder has three modes. The first lets you cycle through some preset colors with the button. The second will automatically cycle through these colors. The third fades colors. The lights are not individually addressable so they are all the same color at any given time. The modes are selected by holding down a single button for different lengths of time while a buzzer beeps to let you know what mode you are in. At $50 its a little expensive but I immediately thought it looked hackable so I bought one.
It sat around the house for several days as I debated what to do with it and waited for a bit of leisure time. I knew I couldn’t just install it as intended. That wouldn’t justify the $50. So like any good hacker I did some googling to see what others had done. I did find some “hacks” but they consisted of “hey look I put these lights on my TV” or “here they are in a box, isn’t this cool.” I’m sorry, I may be a geek snob but using something pretty much the way it was intended is not a very cool hack.
So the debate went on. I cracked the control module open by removing the four screws and found a fairly simple circuit. It consists of three transistor pairs which drive the red, green and blue LED lines, a piezo buzzer, a button, a 5v regulator and a 12F629 PIC microcontroller. The circuit has only the three LED driver channels and that is why the LEDs are always the same color. I thought about building separate RGB drivers for each of the for LED strips so I could get four colors at once but in the end I decided that building new drivers circuits from scratch would take much more time than I wanted to invest in this project. Finally, I decided the simplest thing I could do, that was still “cool”, was to interface the controller with my computer to control the LEDs. Anything is cool when it’s connect to your computer right?
Unfortunately the PIC 12F629 does not have a serial port so I decided to piggy back one of my favorite little microcontrollers on top of the PIC, the ATTiny2313. This chip has plenty of IO lines, PWM, a serial port, is pretty easy to use and I happened to have some lying around and some prototyping boards already made up for them. Here is a picture of the prototyping boards I use:
The picture shows a populated proto board from the top on the left and an unpopulated board from the bottom on the right. You may notice that the picture shows an AT90S2313. This is the predecessor to the ATTiny2313 and is pin compatible. I did end up going with the ATTiny2313 for this project. Here is the schematic in Eagle CAD format and images so you can make your own proto boards:
These images should be printed at 600 DPI for correct sizing. I used a laser printer press and peel type method to get the pattern on to copper clad boards and then etched them. Google it and you will find plenty of information on this.
Something like this could also work instead: AVR ATMEL PROTOTYPE BOARD.
The proto board is populated with the following:
- 1 x 10Mhz crystal clock
- 2 x 22pF capacitors
- 1 x 1uF capacitor
- 1 x 6 pin dual row .1″ pitch ISP for in circuit programming
- 1 x 4 pin right angle header for logic level serial port connection
- 1 x small jumper wire connecting the two extra holes from the microcontroller to the 6-pin ISP
- 1 x ATTiny2313 Micro controller. I recommend you also socket it in a 20-pin socket.
In this project, I also added a single row right angle 8-pin .1″ pitch header to connect to the Dioder and a matching female header socket.
Here is a picture of the soldered proto board from the bottom.
You will notice the serial send and receive wires and a ground wire connected to the 8-pin single row header. I also had to cut the trace connecting that ground pin to the microcontroller.
After soldering and testing the proto board I soldered 7 small wires on to the pins of the PIC12F629. The wires were connected to all but pin 3 of the microcontroller. The diagram below shows how the PIC’s pins are used in the Dioder:
Pin 3 is not used and is just pulled to ground.
Below is a picture of the Dioder’s circuit with wires attached. In this picture there is one wire too many (pin 3).
Here is a close up:
The glossy stuff is solder flux. You might also notice that I scraped off the green coating from the trace coming from the +5v input to the microcontroller. This trace was later cut and another wire was attached to the end not on the microcontroller’s side. This makes it possible to enable or disable the PIC from the AVR making all the functionality of the PIC still available.
Here is the final wiring with hot-glue to hold everything in place:
The wires were connected as follows:
| Signal |
PIC pin |
AVR pin |
AVR function |
| +5v |
NA |
20 |
Vcc |
| PIC +5v |
1 |
11 |
PD5 |
| Buzzer |
2 |
13 |
PB1 |
| Button |
4 |
12 |
PB0 |
| Green |
5 |
15 |
PB3 |
| Blue |
6 |
14 |
PB2 |
| Red |
7 |
16 |
PB4 |
| Ground |
8 |
10 |
GND |
Then to allow the wires to come out of the Dioder control box I cut a small hole in the upper part of the plastic shell with a box cutter.
Here is the cut shell:
After trimming and connecting the wires to the 8-pin female .1″ pitch header here is the finished hardware:
Trust me I really did end up using an ATTiny2313. The chip pictured above ended up being bad and had to be desoldered. That’s one reason it is a good idea to use a chip socket.
Once the hardware was completed all that remained was the software. There are two parts. One the code that goes on the ATTiny2313 and two the PC side software.
The ATTiny2313 firmware is fairly simple. It listens on the serial port at 38400 baud with no parity 1 stop bit and 8-bit data. When it receives a command it recognizes it sets values for the red, green and blue PWM pulses. The firmware uses the ATTiny2313’s built in hardware PWM in 8-bit mode. The PWM is very fast an produces lighting which is much less jittery then the original Dioder.
You can check out the source from my subversion repository like this:
svn co https://cauldrondevelopment.com/svn/dioder-hack/
I built the software in Ubuntu Linux. First install the following packages:
sudo apt-get install gcc-avr avrdude build-essential
Then in the trunk directory run:
This will build dioder.hex and set_color as well as some other files.
You can also find the binaries here: dioder.hex, set_color
To program dioder.hex in to the AVR microcontroller I used Atmel’s AVR ISP mkII. There are many AVR programmers out there and you can even build your own but the mkII is cheap and effective. With the mkII plugged into the USB hole and the other end connected to the 6-pin ISP programming port on the proto board, oriented so that the little tab points down towards the 4 pin serial header, run the following to program the chip:
This will run avrdude to program the AVR. If you use a different programmer you may need to change the Makefile. This can also be done in Windows but you are on your own there.
The 4-pin port on the proto board is a logic-level (i.e. 5v) serial port. This can be connected to a Brainstem USB to serial converter from Acroname. There are other ways to do this. For example, you could wire in your own MAX232 serial level converter and a 9-pin serial port but many computers don’t have actual serial ports these days.
Once everything is connected you can open the USB serial port in a terminal program, set the parameters to 38400 baud N81 and start playing with the pretty lights. Here are the keyboard commands:
| r |
Toggle red |
| g |
Toggle green |
| b |
Toggle blue |
| o |
Turn everything off. |
| 0 |
Disable the PIC. (default) |
| 1 |
Enable the PIC (The Dioder will support all its normal functions). |
This is fun for a few minutes but then you’ll want to set other colors. This is where the set_color program comes in. It is not very smart. It just opens /dev/ttyUSB0 and sends color commands. If your serial port is on another device then you will have to change the code and rebuild. set_color also does not even try to configure the serial port. You will have to make sure it is configured correctly first. If you configure the port in a terminal program, such as minicom, and then exit it should leave the serial port in the correct state.
set_color can be run as follows:
The above command should make the lights a yellowish orange. The numbers are color values from 0 to 255. The order is red, green, blue.
With a little shell script you can fade the colors like this:
while true; do for i in $(seq 1 255) $(seq 254 -1 2); do ./set_color $i 4 64; done; done
This will fade the lights back and forth between light blue and light pink. You can stop it with CTRL-C.
Here is another cool one that is very hacky:
cat /dev/urandom >/dev/ttyUSB0
This one might leave the Dioder PIC enabled.
So where do we go from here? Here are some ideas I have about improving this:
- Write a nice python program for controlling the hacked Dioder with a pretty GUI interface for selecting colors and choosing color change patterns.
- Use the hacked Dioder to indicate events such as email arriving, twitter tweets or certain tags in news feeds.
- Change colors based on the weather outside or somewhere else.
- Build the four channel Dioder hack I decided I didn’t have time for.
So in the end I was quite happy with the hack. It was entertaining and now I have computer controlled color LED lighting to show off. If you found this article useful, built this hack for yourself or have other ideas for the Dioder or other Ikea LED products for that matter, I’d love to hear about it.