Lego Sky

Over the weekend, I had a chance to finish up a project that I started (and immediately became distracted from) several weeks ago.

In our house, Paul and I have a game room. This is where the video games live, as well as other assorted geekery. We have Magic cards, D&D books, some manga.. it’s super nerdy :)

Best of all, Paul has a Lego city on display. We had been looking for an interesting way to add light to the city, so when I saw some RGB LED light strips for sale at Ikea, I knew I had to mod them. In their stock configuration, these light strips can do boring fully-saturated colors, and you switch between them with a boring push-button switch.

After ripping apart the Ikea light and rummaging through my junk drawers, I came up with this:

Touchpad DIODER in action

The Altoids tin has the modified driver circuit: It’s the original circuit board with the microcontroller removed, then a homemade Arduino clone to control it. The orange box is an old Cirque PS/2 touchpad, removed from its original case and covered in fabric.

The Arduino sketch (firmware) is a little C++ program that reads the touchpad and uses it to control Hue and Lightness in the HSL color space. The result is a pretty intuitive and unobtrusive control which makes it easy to both pick a color and desaturate it toward white or dim it toward black. You can easily get some really nice sunset and sky colors.

I measured the power consumption of the completed light at between 1 and 6 watts. With Bay Area electric rates, this means you’d pay about 7 cents a month to leave it plugged in with the lights fully off, twice that to constantly backlight your Lego city in a dim orange glow, and a maximum of 50 cents a month to run the light at full brightness continuously.





For many more pictures of the final installation and the build process, check out my Ikea DIODER set on Flickr.

Comments
14 Responses to “Lego Sky”
  1. Anonymous says:

    bad ass

    I ♥ you

  2. Dang. I just put together my own HSL LED controller, my first significant Arduino sketch. My first attempt uses a trio of potentiometers, but I was hoping to eventually use a touchpad. I guess there really isn’t anything new under the sun (or, in this case LEDs).

    My implementation has an unpleasant degree of flickering when adjusting hue… since I do a quick-and-dirty oversampling of the potentiometers, I attribute this ‘noise’ to floating point precision errors. Your HSL/RGB math looks pretty similar to mine (also from Wikipedia)… have you had the same experience?

    In any case: bravo!

  3. Micah says:

    Thanks! Great minds think alike? ;)

    I haven’t noticed any flickering per se, though it does suffer from limited resolution near the high and low end of the luminance range. That’s probably entirely due to the 8-bit PWM, though. One of the software changes I’d like to make in the future is to improve the PWM resolution. Maybe 12-bit? I have plenty of CPU cycles to burn on an interrupt-driven PWM routine.

    –Micah

  4. A general-purpose, 10b software PWM library would be handy, as it would match the precision of the ADC. A lot of projects seem to use potentiometers to control PWM output in one way or another.

    I have yet to look into AVR/Arduino interrupts myself, but it’s on the to-do list. I’ll also have to check out PS/2 on the Arduino… I used a hacked PS/2 mouse as wheel encoders (and go/stop button) on a little Propeller-based robot and it worked quite well.

  5. Anonymous says:

    Balu

    Those are common RGB diodes?

    I always wondered, because I was not really able to identify the possible color combinations with the auto-switching examples at ikea…

  6. Anonymous says:

    Re: Balu

    Also what the heck is the buzzer for in the original layout?

  7. Micah says:

    Re: Balu

    Yep, they’re common RGB diodes. The light strips themselves are fairly typical 12-volt modules with integrated current limiting resistors. In the standard configuration, the LEDs are normally full-on or full-off (8 colors possible), but even the stock microcontroller does have a mode which uses PWM to fade between colors in a pre-set way. With your own microcontroller, you can do much fancier things with PWM.

    The buzzer in the original control box was just used to get audible feedback for the mode you’re in. You would press the button to cycle through modes, and it would beep each time to indicate which mode it’s in.

    –Micah

  8. Micah says:

    Cool. I’ll definitely post the generic PWM library if I end up writing it. Seems like the kind of thing that a lot of Arduino hackers could use. I’m still getting used to the Arduino culture myself- this is my first Arduino project. I come originally from a PIC background, and more recently I’ve been using AVRs and the Propeller for most of my projects. I love the Propeller :)

    –Micah

  9. Anonymous says:

    Re: Balu

    Thanks a lot for the fast reply. Looks like they are perfect for modding :)

  10. Man, if I knew this was going to hit the Make blog I would have actually built something cool instead of just throwing some basic sets up there. Caught with my LEGO pants down!

    Still, you continue to be the best boyfriend evar. <3

  11. Anonymous says:

    Just what I was looking for!!!!

    I have been looking to do the same thing for one of my on going projects. Thanks Dude!!!

    Jim (Xbox 360 King)Jackson

  12. THIS IS AMAZING

    Would it be possible to instead of have the touchpad, have a microphone that would change the brightness ect. this would so really good when listening to music

    Thanks

  13. THIS IS AMAZING

    Would it be possible to instead of have the touchpad, have a microphone that would change the brightness ect. this would so really good when listening to music

    Thanks

  14. Per Jensen says:

    Hmm, where does clockPin and dataPin declared in the code ? Trying to compile it, i just get a “‘Color’ was not declared in this scope”.

    It looks like the .pde is incomplete. I have written a similar code to read sbsolute coordinated from a Synaptics touchpad, and wanted to see this code in action to see how the HSL to RGB conversion works, but simply cannot find heads or tails in the code :-/

Leave A Comment