diy ambient orb with arduino update <77> comment page 3

Not rated 20,957

Circuit Image

The hardware consists of an Arduino board connected via USB to a laptop, which recognizes the Arduino as a serial device. Three LEDs (red, green, blue) are mounted directly on the Arduino board using a prototyping shield. The schematic is straightforward: the code sketch running on the Arduino is a modified version of one presented in a previous Spooky Arduino class. Instead of parsing single color values over the serial port, it expects a full RGB color value in the standard web format of #RRGGBB (where white is #ffffff, blue is #0000ff, etc.). The sketch parses this seven-character string into three bytes corresponding to the brightness values of the red, green, and blue LEDs. To connect the Arduino to the internet, a small Processing sketch was created that utilizes the standard Java class to fetch a web page (essentially 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 it to the Arduino using the Processing Serial library, and sets its own background color to match. The frame rate of the sketch is set to 1 frame per second, allowing a second for the background to align with the orb's color, providing a sense of the color before it is fully displayed. The matching of the two colors has been surprisingly accurate. There is also PHP code available that retrieves current temperature data using Yahoo's APIs and maps it to an RGB color. After 3 PM, it displays the temperature for the following day (localization may be required). The implementation of a pulse feature to indicate precipitation chances is still in progress, with initial code provided for experimentation. The code is somewhat disorganized, and the color mappings for temperatures may require refinement. There is a partial implementation of the pulse feature, which maps some of Yahoo's weather codes to it (e.g., chance of showers = 1). Adjustments are being made to include a pulse variable so that the orb can pulse when precipitation is forecasted, with different pulsation patterns for varying rainfall levels. Suggestions are welcome regarding the best approach to handle the pulsing, including potentially writing a function to create a pattern for BlinkM and adjusting its playback timeline and fade rate. There are challenges in calculating a smooth fade from an arbitrary color in RGB space. The built-in BlinkM flash scripts use HSB and adjust brightness. The URL for the color source should be changed to a file on a controllable server. Editing that file will update the Arduino's color accordingly. Local file access using file:// URLs may be possible, but has not been tested. An error related to a missing font file (Futura-MediumItalic-48.vlw) is noted, with instructions to create the font file via the Tools menu in Processing and adjust the filename in the loadFont() line accordingly.

The described circuit involves an Arduino board functioning as the central controller, interfacing with three RGB LEDs to create a visual representation of color values received via a web page. The connection between the Arduino and the laptop is established through a USB interface, allowing for serial communication. The LEDs are directly mounted on the Arduino board using a prototyping shield, facilitating ease of assembly and modification.

The Arduino sketch is designed to interpret RGB color values formatted as #RRGGBB, which are common in web applications. This format allows for a wide range of colors to be represented, enabling the LEDs to display various hues. The Processing sketch serves as a bridge between the web server and the Arduino, fetching color data from a specified URL, parsing it, and transmitting it to the Arduino via the serial port. The synchronization between the background color of the Processing sketch and the LED colors on the Arduino is achieved through a deliberate frame rate setting, which creates a visual delay that enhances user perception of the color change.

The inclusion of PHP code to retrieve temperature data and convert it into RGB values expands the functionality of the project, allowing for dynamic color changes based on real-world data. The implementation of a pulsing feature to indicate precipitation chances adds an additional layer of interactivity, making the project more engaging. The challenges in refining the pulse variable for different rainfall levels indicate an opportunity for further development and experimentation.

Overall, the project showcases the integration of hardware and software, utilizing the Arduino platform, Processing environment, and web technologies to create a responsive and visually appealing system. The modular nature of the code allows for future enhancements, such as improved color mapping and additional environmental data integration, making it a valuable learning tool and a foundation for further exploration in interactive electronics.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: 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.

To bridge between the Arduino and the Net, a small Processing sketch was created that uses the standard Java 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! 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. 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).

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) 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. 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: 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. Had some fun wit 🔗 External reference