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.

Hardware

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:
rgb_led_schematic.png

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

66 comments to DIY Ambient Orb with Arduino, update

  • Hi Dave,
    There are many examples of that on the Arduino forums and other places. The code is pretty short, basically just:

    void loop() {
      int r = analogRead(redSlider) / 4;
      int g = analogRead(grnSlider) / 4;
      int b = analogRead(bluSlider) / 4;
    
      analogWrite( redPin, r );
      analogWrite( grnPin, g );
      analogWrite( bluPin, b );
    }
  • Rick Blight

    Hello everyone,
    I was wondering if anyone has successfully implemented the ‘pulse’ idea. I have my arduino running my lamp and it looks beautiful; I would love it it it could “display” precipitation. Either pulse, or light up a separate LED or two.

    Thanks!
    Rick.

  • Hi Tod!
    Thx for this wounderful “project”! I am just wondering if I had missunderstand it a bit, or if it is just my computer that is a blit spoooooky!

    For me, after a while the RGB LED starts to change color by it’s own. Is it ment to be like that?
    If it is ment to be like that can you help me fix the code so it doesent make that? :)

    // Nisse from Sweden :)

  • Daniel Cooper

    10: error: #include expects “FILENAME” or <FILENAME
    Does anyone know about this error code cant get past it need HELP?

  • Hi Daniel,
    Can you please describe exactly what steps you are taking to produce that error? Also, what version of Arduino and what OS are you on?

  • Jeff

    I got it running, and it is super cool! I have a dedicated laptop so that it runs 24/7. Looking at the PHP, I see where the “pulse” idea is implemented, but I can’t follow it to the code running on the Arduino or in Processing. Am I crazy, or does it not exist? If I am sane, and it isn’t there, how would I go about implementing it?

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>