DIY Ambient Orb with Arduino, update

There’s been some confusion as to whether or not the DIY RGB orb presented in the last post was actually connected to a computer and receving color data from it. Here’s a video that more accurately depicts what’s going on and all the code used to create it.


The hardware is just an Arduino board connected via USB to a laptop. The Arduino appears as a serial device to the computer. On the Arduino board, three LEDs (red,green,blue) are mounted directly to the Arduino board using a prototyping shield like this DIY one. The schematic is quite simple:

Arduino code

The code sketch running on the Arduino board is a slightly modified version of the one presented in the last Spooky Arduino class. Instead of parsing single color values over the serial port, it expects a full RGB color value in standard web format of “#RRGGBB” (white is “#ffffff”, blue is “#0000ff”, and so on). The sketch parses that seven character string into three bytes: one each for the brightness values of the red, green and blue LEDs.

Arduino code: serial_rgb_led_too.pde

Processing code

To bridge between the Arduino and the Net, a small Processing sketch was created that uses the standard Java HTTPURLConnection class to fetch a web page (really, a text file on a web server) containing a line with a color value in the format “#RRGGBB”. The sketch parses the color value, sends the value out to the Arduino orb using the Processing Serial library, and then sets its own background color to match. Because I’ve set the framerate of the sketch to 1 fps, it takes a second for the background to match the orb. I did this on purpose so I could get a sense of the color as the orb reproduces it before seeing it as it truly is. I was surprised how well the two tended to match!

Processing code: http_rgb_led.pde

73 Replies to “DIY Ambient Orb with Arduino, update”

  1. Has anyone come up with any cool websites i.e. giving users access to a set of sliders to determine the color of the light?

  2. Hi tod
    this a great tutorial, thanks for this sharing,
    I have a question regarding the amount of LEDs in pwm channels , My arduino board has only 6 pwm pins, wich makes 2 RGB Leds, ( the megas has more pwm ) but any way
    I need to controll several leds ( from sparkfun )
    and I am wondering if 2 LEDs per channel will be handle well and have good light, what resistor would you recommend (OHMS) for each Led . thank you looking forward to read your post. balam

  3. Hi quikstiks,
    Short answer to your main question: yes, I think an Arduino could handle your 6 analog inputs and 6 LED outputs. The two speaker outputs are emitting sounds computed by a Max/MSP patch on a computer? If so, the Arduino isn’t really involved in that, but it would be sending data from its inputs to Max.

    I tend to think in terms of input->output flows. It sounds like there are two major flows. First, there’s the immediate “autonomous” response of triggering the LEDs based on the various inputs. This is a totally stand-alone Arduino sketch that could run by itself. And it might be a good starting point for getting everything all together and working.

    Then there’s the “Arduino-as-input-device” flow where the Arduino reads the inputs, sends them to Max/MSP over its serial/USB port, and Max outputs sound to speakers. I assume the Max patch is doing some sort of algorithmic generation of sound. If you’re happy with just triggering lofi samples instead, you could add a Waveshield on top of the Arduino and have it play the sounds directly.

    But if you don’t do that, you’ve got two cables running from the computer to each Orb: a USB cable and a speaker cable.

    This project sounds really cool. Send me some links when you get it up and running!

  4. Hey Tod,

    Loving the project. I’m making use of the Orb as part of a project which involves IR sensors, piezos and the LED orb.

    Basically the project is as follows:

    – There will be two orbs set up at opposite, diagonal corners of a square space. Two IR sensors will be set-up to detect the user’s proximity from the orb(s).
    – As the user approaches the orb(s), the LEDs trigger intermittently; the closer the user to the orb, the less delay will be between (LED) flashes. The IR controls the strength of the LEDs and will also trigger synchronised sound.
    – When the user is within a certain range, the sound/light will turn from intermittent to static.
    – At this point, the user will be within touching range and piezos will be attached to the orb. Touching the orb will trigger additional sounds and possibly random LED value changes.
    – The Colour of the LED’s will only change upon touch.

    My question is will the Arduino be able to handle 2 analog IR inputs, 4 analog piezo inputs and 6 digital LED outputs, 2 loudspeaker outputs, all doing the above, hopefully, through Max?!

    I think the only way of working an orb in the opposite corner is running a series of long cables from a second, slave breadboard to the master breadboard/arduino?

    Any thoughts or tips? Anything that I’ve missed potentially?

    (I plan on programming using Maxuino)
    LED’s = 2.5v/4v fwd, 5v Rev
    IR = Sharp 2YOA21
    Piezo = Piezo transducer 35mm/28kHz/Max. 30V. input p-p.

  5. hello everyone,

    i am a production LX a who is trying to find or make a whole lot of color changing orbs which could all be controled remotley and what is on this page looks like the kind of thing i am looking for. if they could be DMX controlled it would be great but they dont have to be. the only thing is that the orbs have to be able to give at least 50-60 watt equivalent. if anyone has any ideas of how to help me out it would be great

  6. Had some fun with your ambient orb idea and got one working really well in automatic fashion. My daughter has an “egg” toy that cycles through red, green and blue but doesn’t mix colors well enough to do the entire rainbow. With an RGB LED and some mods to your code, I was able to make one that hits all of the colors.

    This was my first foray into Arduino and I just wanted to say thanks for getting me started. Can’t wait to see what else I can do with this thing.

  7. Hi Harry,
    The useful bit of the error is buried in that mess, but what it’s saying is that the font file “Futura-MediumItalic-48.vlw” doesn’t exist. If you notice in the Processing sketch, there’s the line:

      font = loadFont("Futura-MediumItalic-48.vlw");

    To create this font file, go to the “Tools” menu and choose “Create Font…”. Pick whatever font you want (I picked 48-point italic Futura). Note the filename and click “OK”. Then go to that “loadFont()” line and change the filename to match your choice.

    If you want the exact font file I used, you can download it here:
    This font file goes in the “data” directory of your sketch. When you use “Create Font…” it sticks the font files in the “data” dir for you.

    For more information on fonts in Processing, see:

  8. This is the error I get from the processing. Can you help?

    2008-05-30 14:18:01.194 java[1987] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0x11403, name = ‘java.ServiceProvider’
    See /usr/include/servers/bootstrap_defs.h for the error codes.
    2008-05-30 14:18:01.212 java[1987] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)
    at processing.core.PFont.(
    at processing.core.PApplet.loadFont(
    at Temporary_833_314.setup(

    java.lang.RuntimeException: Could not load font Futura-MediumItalic-48.vlw. Make sure that the font has been copied to the data folder of your sketch.
    at processing.core.PApplet.die(
    at processing.core.PApplet.die(
    at processing.core.PApplet.loadFont(
    at Temporary_833_314.setup(
    at processing.core.PApplet.handleDisplay(
    at processing.core.PGraphics.requestDisplay(

  9. Hi ,
    we are very interested in finding a someone to custom make orbs for us , would you be interested?

  10. Hi Matt,
    This post is basically the entire set of notes for this project. The Processing code does three things:
    1. Fetch a text file from a URL denoted by the variable “urlstr” (it’s set to “” right now)
    2. Parse that text file for the first line that starts with “#” and contains 6 numbers.
    3. Send the parsed RGB color down the serial port to Arduino.

    You’ll want to change “urlstr” to a file on a server you control. Then whenever you edit that file and change the color, the Arduino will follow suit. You might be able to use “file://” URLs to access a local file, but I’ve not tried that.

  11. Can you point me back to the original notes on this project. I don’t understand the Processing portion, it just sits there on red. How does it get colors of the web? Do I need to edit the text, have another software program running? Thanks.

  12. Oh thanks for catching that bug. I’ll update the BlinkM examples zip to include the fix. And if you “hog up” the comments with improvements to my code, hog away! :-)

  13. Hogging the comments! Sorry!

    When I try to compile BlinkMScriptWriter, I get:

    error: too many arguments to function ‘uint8_t readSerialString()

    looks like the line just inside of the loop() should read:

    if( readSerialString() ) {

    (remove the serInStr argument)

  14. I’m mucking up todbot’s code to include a ‘pulse’ variable so that my kludged orb can pulse when there’s precipitation forecast. A quick ‘throb’ for high rainfall, a slight pulse for light rain and a solid color for no rain.

    Anyone have thoughts on the best way to handle the pulsing? I was thinking of writing a function that would write a pattern to BlinkM, then have my code adjust BlinkMs playback timeline and fade rate to offload that process to BlinkM.

    In practice, this is looking to be a bit more work than I’d anticipated – calculating a nice fade from and arbitrary color (I’m using RGB color space). Are the ‘flash’ in-built BlinkM ‘flash’ scripts using HSB and simply adjusting the B(rightness)?

    I guess I could handle this all on the Arduino, but it just seems less… elegant. Any thoughts on this?

  15. I have some PHP code that I wrote to display glanceable weather info on a Chumby. I’m trying to replicate the behavior of my Ambient Weather Beacon. Thought y’all might like to experiment with it in conjunction with this project.

    The code grabs today’s temp using Yahoo’s APIs and maps the temp to an RGB color. After 3pm, it should display tomorrow’s temp (you may need to localize it).

    I haven’t really implemented the pulse that Ambient’s devices do to show precipitation chances, but the beginning of the code is there if you want to experiment.

    It was a simply thing to interface this with todbot’s Processing/Arduino example.

    The code’s a bit messy, I’m not great with PHP. The specific colors chosen for each temp could probably use a bit of work, too. But, hey – it’s a start for you to work from if you’re interested. I’ve only partially-implemented the pulse by mapping some of Yahoo’s weather codes to it (chance of showers == 1).

    It’s going to output something like:

    (pulse is from 0-3, 0 being no chance of rain, 3 being “extreme weather”)

    Ambient Orb Weather Predictor

    Hope you find this useful. You’ll need PHP5 (I used simplexml).

  16. Oops! You’re right Scott. Apologies to anyone who was having problems with that. And you can use any font your system has installed; I just happened to like Futura.

  17. Loading and altering “http_rgb_led” from this example was my introduction to Processing.

    For anyone that’s having trouble getting the example to run, you’ll need to create a font file to use as the argument for loadFont().

    Use the “tools>>create font” option in Processing, then use the name of the font file you created as the argument for loadFont.

    Hope this acts as a guidepost for future newbs passing through…

Leave a Reply

Your email address will not be published. Required fields are marked *