Build it: a smart, ambient LED

An Arduino-powered LED photo cube.

The finished project.

Ambient technology is the current rage for presenting information in a unobtrusive and, sometimes, sublime manner. Information suited for an ambient format ranges from complex number-laden data streams to simple one- or two-digit numbers. The idea here is that you can glean the same information by simply looking at the color of a cube, rather than consulting a sensor’s text output.

While this project doesn’t directly take advantage of ambient technology, it does show you a great method for generating a simple color-changing LED that can be integrated into any number of projects. By combining the open-source Arduino microcontroller circuit board with a “smart” LED called BlinkM, you can build a simple mood cube that randomly generates a spectrum of sumptuous colors.

By pairing a sensor with this Arduino-based mood cube to input data, you can create a more ambient-like experience:

  • Ambient Mood Cube: Install an ultrasonic motion detector and have the cube change its color due to your personal proximity. Kinda like a colorful greeting for a close encounter.
  • Interactive Ambient Art Cube: Add an accelerometer and create a cube that changes its color based on X-Y-Z orientation. Play with it, toss it around; the color changes due to your movements.
  • Weather Cube: Connect a barometric pressure sensor to the Arduino and program specific color changes for different barometric pressure readings. For example, make high pressure green, low pressure red, rising pressure, blue, and falling pressure yellow.
An 8-by-5 grid of images showing the ambient light Mood Cube cycling through various colors.
An approximately two-minute run of a “random” color sequence from the Mood Cube. Dave Prochnow


  • Time: 1 hour
  • Cost: $74.99 (battery-powered version)
  • Difficulty: easy


Power options


1. Cut six 2¾-inch squares of self-stick matte paper. Apply each square to one window of the photo frame cube.

2. Plug the BlinkM LED into the analog pins 2-5 of the Arduino USB board.

3. Determine which power option you would like to use. If you select the battery option, solder the 9-volt battery snap connector to the 5.5/2.1 coax plug. Alternatively, you can power your color mood cube through the USB port of your PC.

A 9-volt battery attached to a clip-on power supply.
A DIY 9-volt power supply for the Arduino-based Mood Cube. Dave Prochnow

4. Program the Arduino board with our sketch code (below). This code will occupy approximately 4584 bytes of Arduino’s flash program space.

5. Plug the 9-volt battery into the Arduino board. Move the Arduino power supply selection jumper to the EXT position. Install the board inside the cube. Bask in the vibrant glow of your continually changing color cube.

An Arduino microcontroller and a BlinkM LED inside a photo frame cube.
The Arduino and BlinkM installed inside the photo frame cube. Dave Prochnow

Arduino sketch code

Here is the program used to generate random colors for the BlinkM LED.

  * le Color Cube

  * 26 Feb 08

  * Derived from BlinkM code
  * @
  * BlinkM
  * Arduino Diecimila

_// BlinkM connections to Arduino_
_// PWR - -- gnd -- black -- Analog Out 2_
_// PWR + -- +5V -- red   -- Analog Out 3_
_// I2C d -- SDA -- green -- Analog In 4_
_// I2C c -- SCK -- blue  -- Analog In 5_

_// Note: This sketch resets the I2C address of the BlinkM._

#include "Wire.h"
#include "BlinkM_funcs.h"


_//New BlinkM address_
**int** blinkm_addr = 0x10;
_//Color variables; red, green, & blue, will be assign a random value_
  **long** red = 0;
  **long** green = 0;
  **long** blue = 0;

**void** setup()
_//Random noise on Analog Pin 0 will set a random number seed_

  _  //Setup BlinkM: pins, address, script halt, fade speed_

**void** loop()
_//Seed red with a random value_
  red = random(257);

    BlinkM_fadeToRGB(blinkm_addr, red, green, blue);

_//Seed green with a random value_
  green = random(257);

    BlinkM_fadeToRGB(blinkm_addr, red, green, blue);

_//Seed blue with a random value_
  blue = random(257);

    BlinkM_fadeToRGB(blinkm_addr, red, green, blue);