Home > Electronics > Mood Rock

Mood Rock

September 19th, 2009

I was in an art store and came across a neat looking alabaster rock.


And for some reason, I thought it would be cool to stick some lights in it, which started yet another project. I started out by building a circuit on the cheap using some components I had lying around.



I thought it would be cool to control the color from the PC, so I decided to check out the AVR-USB project. The cool thing about AVR-USB is that it handles the USB protocol in firmware alone and doesn’t require any additional ICs. I had a number of hickups – the biggest one being that as soon as a USB packet was received, the SPI on the AVR would stop working. After many hours of not being able to figure out the culprit, I resorted to bit-bang SPI and everything started working. The lights are shiftbrites from macetech. The cable is an ISP programming interface for the AVR. Component count is fairly low – a crystal, a bypass cap, a supply cap, two USB termination resistors and a pullup resistor.

I used a masonry bit to drill a lot of holes in the bottom of the rock, then used a hammer and chisel to finish enlarging the space. The board just barley fits in there.


And the effects were pretty cool..



The communication is via a modified hidtool.c application (an example shipped with AVR-USB) which transmits a 4 byte payload which is then shifted onto the LEDs. For completeness, I wrote a small application in perl to act as a webserver and handle requests – forwarding valid requests to the hidtool application. And I also put together a nice color picker front end which uses AJAX to update the color on the fly. So as you move the color picker, the rock changes color accordingly. I put together a video of everything working together here :

There is a small amount of lag, which is to be expected — the chain of operations is…

  1. open web app, and pick a color
  2. color picker uses AJAX to send requests to a server running on my desktop
  3. server forks hidtool.exe with the color arguments
  4. hidtool then connects to the USB device (rock) and transmits the new color strings.

This chain of events is repeated every time the color changes – this happens as the cursor is being moved around thus it can generate quite a few requests. To improve throughput, I would need to merge the C app into the perl app, or visa-vera.

I’ve gone ahead and put the application online here so go ahead and set your mood color which will be displayed on my rock.

Live Feed

This image is updated every 5 seconds.  Or go here.


Electronics , , , , , ,

  1. | #1

    Hi Reza. The color picker is cool. I just tried to use it with my USB IKEA DIODER but your perl webserver link is broken. Could you post it, too? :)

  2. admin
    | #2

    Thanks for the comment, I fixed it. Sorry, it’s my ISP (1and1.com) being overzealous and changing permissions on the file. They sent me letter saying that I was not supposed to run a server on their server – which I wasn’t – I didn’t realize that they mucked with the file permissions as well. I sent them a nasty email telling them not to mess with my web content.

  3. | #3

    HelloWas just surfing the net on this nice sunday morning and came across your great post. Thanks for a very good read. I bookmarked your page.

  1. | #1
  2. | #2
  3. | #3