BlinkM Hello, Video Guides, Example Code

This is a BlinkM:

BlinkMs are “smart LEDs”, a type of smart interface component. A BlinkM consists of an ultrabirght RGB LED backed with a microcontroller with built-in knowledge about 24-bit color spaces, color fading, and color pattern generation. All in a package 0.6” wide. You talk to it over I2C, a serial protocol spoken by many different things. (Arduino speaks it, as do Basic Stamps, and your PC) And you can have over 100 BlinkMs on the same serial bus, each individually addressable. Here’s how they can hook up to an Arduino:

BlinkMs are available from SparkFun (US) and Little Bird Electronics (AU). It’s hard to show in just static pictures how fun and easy it is to play with BlinkMs, so here’s a few quick video guides.

Video Quick Start Guide

A video version of the BlinkM Quick Start Guide.

Playing with BlinkMTester

A demonstration of one of the example Arduino sketches “BlinkMTester”, which lets you exercise a BlinkM by typing simple commands to the Arduino.

Exampe Code

There are a couple of examples of how to talk to BlinkMs all zipped up in BlinkM_Examples.zip. You can also peruse them unzipped if you like. The examples are predominately for Arduino currently, but any I2C master will work. Some of the examples so far:

  • BlinkMCommunicator
    A simple serial-to-i2c gateway for PC controlling of BlinkM (for instance via Processing or the BlinkM Sequencer)
  • BlinkMTester
    A general tool to play with a single BlinkM
  • BlinkMMulti
    An example showing how to communicate with multiple BlinkMs
  • BlinkMScriptWriter
    A demonstration of how to write BlinkM light scripts with Arduino
  • BlinkMChuck
    Control the hue & brightness of a BlinkM with a Wii Nunchuck

More examples will be added periodically.

For the Arduino examples, a convenience library called BlinkM_funcs.h has been created. Just drop this .h file into your sketch folder and call the functions to start playing with BlinkM.

The complete list of functions is below, though you’ll probably only use a few of them for a particular project.

BlinkM_begin();
BlinkM_beginWithPowerPins(byte pwrpin, byte gndpin);
BlinkM_beginWithPower();
BlinkM_sendCmd(byte addr, byte* cmd, int cmdlen);
BlinkM_setAddress(byte newaddress);

BlinkM_setFadeSpeed(byte addr, byte fadespeed);
BlinkM_setTimeAdj(byte addr, byte timeadj);

BlinkM_fadeToRGB(byte addr, byte red, byte grn, byte blu);
BlinkM_fadeToHSB(byte addr, byte hue, byte saturation, byte brightness);
BlinkM_setRGB(byte addr, byte red, byte grn, byte blu);

BlinkM_fadeToRandomRGB(byte addr, byte rrnd, byte grnd, byte brnd);
BlinkM_fadeToRandomHSB(byte addr, byte hrnd, byte srnd, byte brnd);

BlinkM_getRGBColor(byte addr, byte* r, byte* g, byte* b);

BlinkM_playScript(byte addr, byte script_id, byte reps, byte pos);
BlinkM_stopScript(byte addr);
BlinkM_setScriptLengthReps(byte addr, byte script_id, byte len, byte reps);
BlinkM_writeScriptLine(byte addr, byte script_id, byte pos, byte dur,
                                byte cmd, byte arg1, byte arg2, byte arg3);
BlinkM_writeScript(byte addr, byte script_id, 
                          byte len, byte reps,   blinkm_script_line* lines);

And More

For more information, including a datasheet, example code and sequencer application for Mac/Windows/Linux visit blinkm.thingm.com.

If you want to talk about BlinkM, leave a comment or participate in discussions on ThingM’s Satisfaction page.

53 Replies to “BlinkM Hello, Video Guides, Example Code”

  1. Good to know. Thanks. Unfortunately, I am programmerless, but look forward to the future firmware revision.

  2. Hi Jon,
    There is a beta version of the BlinkM firmware that provides the flow-control features of BlinkM MaxM. If you have access to an AVR-ISP programmer, I can let you test out the firmware by reprogramming one of your BlinkMs (you can always revert back to the original firmware)

    It’s still beta because I’m also working on adding simple digital inputs to BlinkM. Not as flexible as the analog inputs on BlinkM MaxM, but better than nothing. Until that works and I’m happy it doesn’t affect basic BlinkM functionality, current production BlinkMs ship with the original firmware.

  3. Hi, I’ve been having a lot of fun using the BlinkMs in various projects. I was curious to know if you guys had any plans to include jump function from the MaxM in the BlinkM firmware?

  4. Hi,

    C:\arduino\tester\BlinkMTester\applet\/BlinkM_funcs.h:64: error: expected ‘,’ or ‘;’ before ‘{‘ token

    I am getting this error while verifying. I am trying to use Blinkm tester

    Thanks
    Vivek

  5. Thanks for your reply- I appreciate it. BTW, (you don’t have to post this part) on Script #18 (SOS), it is actually outputting “SMS”. Should be easy enough to fix.

    Again, thanks.

  6. Hi Bryan,
    I’ve not had experience with reading back I2C values with a Basic Stamp. It’s been on my to-do list for a few months. My approach to experimenting with this would be to find some existing Basic Stamp I2C examples on the net (like the original BS2 I2C code I based BlinKMTest.bs2 on or this one reading an I2C compass) and change it slightly to fit the style of BlinkMTest.bs2 in the BlinkM_Examples.zip

    The ‘g’ BlinkM command is essentially the same as how one reads a value from any other I2C device. Most microcontrollers that do I2C have examples of reading from I2C EEPROMs, real-time clocks, etc. In fact, it’s so common, that when I was writing BlinkMTest.bs2 I had to struggle to find a BS2 example that _sent_ data instead of read it. :)

    Oh and don’t worry about nuking the firmware. As long as you never disconnect a BlinkM in a powered circuit, no bad things should happen just by sending I2C commands. If you do manage to erase the firmware on one of them, email me and we can arrange an exchange.

    Also “yellow” should just be #FFFF00. You’ll probably need to stick a little diffuser on the top so the colors mix. With LEDs, composite colors look weird unless you can get that mixing. This is one of the reasons I used an RGB LED instead of three independent LEDs, to try to get the three colors as close as possible. You may find that #FFFF00 doesn’t give you the kind of yellow you want. If that’s the case try decreasing the red or green component a bit, sort of like setting the color temperature in Photoshop. I’m sure you’ve already been trying this.

  7. Hi- I bought 4 BlinkMs from Sparkfun, and I have them working correctly. I have looked everywhere, but I am having some difficulty with the “g” command, specifically, how to retrieve the RGB bytes after issuing the “g”. The only reason I am looking in the first place is because I am having a little trouble creating a decent yellow color from the RGB commands, and I want to read the RGB values after setting the color with the HSB command. For sake of this experiment, could you please help me with a line or two of code for a Basic Stamp? I am using the stamp just to write code, but once I figure that out, I will be using a PIC. I did RTFM and have been trying for a little while, but when I read your post about possibly “nuking” the firmware, I got a little nervous about experimenting too much. Thanks.

  8. Hi Neostar,
    Not directly, as BlinkM doesn’t have any inputs on it (BlinkM MaxM does) But if you search around on the Arduino site you’ll see a few forum threads with examples of how people have been hooking up microphones to Arduino. So then you have an Arduino in between the microphone and the BlinkM, and the Arduino can do signal processing on the incoming audio (like basic frequency analysis so you can separate out bass, mid, & high)

    If you’re considering using a MaxM, you’ll need the same sort of mic amplifying circuit using in the Arduino case above but that’s it. Of course, the MaxM just does simple level detection, not frequency analysis, so you’ll mostly just be able to trigger on the bass notes.

  9. I’m wondering can the BlinkM be controlled by sound?

    I was thinking of making the BlinkM react to sound and change colours as the sound changes. Mainly I want to have some kind of connection with music. Maybe using an input from say an iPod and then have the BlinkM react by changing it’s colours in time with the music.

  10. Hi Joe,

    You can do that! Any application on a computer that can send arbitrary byte commands over a serial port can control a BlinkM, after you put the BlinkMCommunicator sketch on the Arduino that goes in-between the BlinkM and your computer.

    The computer application just needs to decide what color it wants the BlinkM to be, then sends the corresponding command over the serial port. The BlinkMCommunicator Arduino sketch takes that and forwards it to the BlinkM.

  11. Hi,
    Thanks for all the info, looks great! I was wondering if was possible to have the blinkm pulse to music with the ardunio receiving some type of serial command from the computer. idk what I am talking about in the slightest but I think I what I want to do ideally is hook up the ardunio to a few blinkms and control them with vixen lights to sync it with music like a mini light show. Do you know if this is possible?

    Thanks in advanced!
    Joe

  12. Hi Bricol,
    Your idea sounds awesome, I think you should try it.
    I’m a big fan of the Arduino board and software. There have been many great tutorials written for people who have little experience with electronics or software. I’ve done two classes (which you can download the notes to), but I recommend going to the Arduino Tutorial section and either reading the tutorials there, or looking through the Arduino Tutorial Links to find a tutorial you like. Tom Igoe’s book “Making Things Talk” is very good.

    None of this stuff is really that hard. If you can follow a recipe, you can get pretty far. Once you’ve played around with an Arduino and gotten a feel for what’s possible, then try your project out. And if you get stuck, there’s always the Arduino forums or blogs like mine to ask questions on. :)

  13. Hi Todd,

    I stumbled across you’re blog and blinkM’s through a post on the forums at the site listed above. These things are pretty amazing!
    The poster there wanted to hook up some blinkM’s to visually show the temperature of the water in his watercooling system for his computer (regulate between blue for cold and red for hot).
    I thought that was a fantastic idea and would be interested in trying it myself. Could you point me in the right direction with this? I have never written a line of code in my life, so it all feels very complicated and I’m a little lost as to where I should start. I was hoping to integrate a thermal sensor that I have that comes with this module http://www.t-balancer.com/english/bng.htm to an arduino (don’t know which one, but I need it small enough to hide in my case) and I figured 2 blinkM’s would be enough to create the effect that is necessary to visually show water temperature.
    Would you be able to recommend which arduino would suit my needs and where I should start in this mini-project? I hope this isn’t too remedial. . .

    cheers!

  14. Wow thanks for the fast reply. So a circuit with a ‘permanenty’ installed pic will remove said limitations. Thanks for the information.

  15. Hi Nicholas,
    The timing ‘ticks’ in BlinkM are 1/30th of second (33.3msec) long, and the largest tick value for a single light script action is 255, which equals 255*(1/30) = 8.5 seconds. In stand-alone mode, there are 48 maximum number of light script actions in a light script, so the longest duration light script can be 48*255*(1/30)= 408 seconds = 6.8 minutes.

    But if you hook a BlinkM up to an Arduino or other microcontroller, you have no time limits on how long your light sequences can be.

    In the fall we’re releasing an update to the BlinkM firmware that will let you select the ‘tick’ resolution, in addition to other features. This release will coincide with the release of the high-power BlinkM MaxM.

  16. I was wondering if there is a limitation on the time delays / durations: for example could I program the BlinkM to sequence over a 24-Hour period (I only noticed 120 secs. in the video)?

    Thanks
    Nick

  17. T-Dawg,
    Each BlinkM draws at most 60mA (when at full-white, like when it first powers up). You can draw 500mA max from a single USB connection, which means the theoretical max number of BlinkMs powered by USB is 500/60 =~ 8 BlinkMs.

    As for how many BlinkMs you’d need for an Ambient Orb, the official Ambient Orb uses the equivalent of 6 RGB LEDs, but from my DIY Ambient Orb I did awhile back, I got pretty good results in a dark-ish room using just one RGB LED.

    Generally with LEDs (of either the regular or BlinkM variety), the more you have, the brighter and more diffuse light you can create. So it depends on your environment how many LEDs/BlinkMs you’ll need.

Leave a Reply

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