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. Looking to buy one of these for my Arduino for use as a nice simple Ambient Orb (like many others!)

    Was just wondering how many of these you can connect to an Arduino while still allowing it to be powered via USB alone (no external PSU, I want just one wire). I’ve seen you connect the one in the video so I know that’s at least possible

    I’m assuming I would just daisy chain the I2C bus and use the common Arduino 5v/GND rail. Just wondering how much power I could get out of it

    Also, how many BlinkMs would you recommend for a nice bright Ambient Orb? Would just the one be fine or would a few look better?

    Cheers!

  2. Hi,
    The easiest way is to send the “stop script” command (‘o’) as soon as you connect to a BlinkM. You can also set the startup parameters to not play a script on startup.

  3. Hi Tod!
    I´m using the Bleything Max/MSP patch to control the led, but i can´t stop the led from playing the internal script.. can you help me on this??
    cheers :)

  4. Ok.. makes sense.. I’ve done similar to power up LCD modules with PICs but they only s/s 25mA. FF is bright enough now. I can wait a while before I hook up “real” 5V.
    Thanks!!

  5. Hi Greg,
    Check out the function BlinkM_beginWithPowerPins() in “BlinkM_funcs.h”. That function does this:

        DDRC |= _BV(pwrpin) | _BV(gndpin);
        PORTC &=~ _BV(gndpin);
        PORTC |=  _BV(pwrpin);
    

    The trick it does is to make two of the analog input pins outputs, and sets one LOW and the other HIGH. There’s no way to do this with the standard analog functions, so straight AVR C is used.
    The pins on an AVR chip (the chip that’s in an Arduino) can supply up to 40mA of current. Since a BlinkM can use up to about 60mA of current when going at full brightness, this means that the maximum brightness is less when plugged into the Arduino in this way than if you ran a real +5V & Gnd lines to it.

  6. Hopefully UPS will deliver my AVRDragon shortly but the BlinkMs and Arduino arrived today. Nice work!! The Arduino was up and running in a few minutes on my PC and the BlinkM is cycling away.

    Now for the fun… :-)

    It’ll probably jump out at me later but what sets up the Analog port on the Arduino to provide +5 and gnd for the BlinkMtester? I looked through the code briefly but I don’t see where that happens ( yet ) or are those the ADC reference pins?

  7. There’s currently a hard limit of up to 49 commands for a light script. This limit is due to the amount of EEPROM in the ATtiny45 chip. I plan on having a firmware upgrade to allow segregation of those 49 commands into multiple scripts, or allow one to use the Flash as script storage space, but that’s a month or so off.

    And yes, if you (or anyone else reading this) have a problem where you think you’ve managed to nuke the firmware, let me know and I can send you the hex file for the firmware. Eventually it will be up on the BlinkM site, perhaps along with other special-purpose firmwares.

    The Atmels are great chips. I think the PICs beat them on really resource-constrained applications where you can fine-tune your assembly language. But I like C and the C compiler for AVRs is pretty good and free.

  8. No problem… After 10 years of PIC dev, I’ve been waiting for an excuse to shift over to Atmel.

    Is there a hard limit ( out of memory,etc…)to the 49 commands in a lightscript? I can see busy applications where I could use more pattern space. Apologies if it’s blinding obvious in the example code.

    Also if I blow away the firmware to make a “general AVR ATtiny45 development board”, is the binary available to restore it back to a BlinkM?

  9. Nice work! You saved me a lot of dev time. I just ordered 10 BlinkMs and an Arduino ( gee,one more dev brd…) to get started. I can hardly wait for them to get here.

  10. ahahahah, I’d love to learn more what you two mean by “funny”? :) I’m responsible for any ‘music’ on these video clips; it’s just me goofing around with Live and a few plugins.

  11. These are wonderful–I just ordered a handful from SparkFun; can’t wait to get them.

    I shared this page with a colleague of mine, and she said “The music on those little clips is funny:)” I agree (in the best way possible). Who is supplying the tunes?

  12. Hi Ben,
    Doh! Apologies. It’s up there now. If you re-download the BlinkM_Examples.zip, it’s in there too. Thanks for catching that.

Leave a Reply

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