BlinkM arduino code

I have recently gotten a couple of BlinkM’s. Has anyone had experience programming them through an arduino? The datasheet on ThingM’s website is perhaps informative to someone who is an accomplished arduino programmer, but I find it impenetrable. Also, none of the example code that is available on the website seems to work for me, and there is little to indicate how to adapt it for personal use. Just to let you know at what level I’m on, I can’t even figure out what code belongs in void setup() and what belongs in void loop().

Does anyone have some simple working arduino code for BlinkM’s that they would be willing to share, so that I can get a sense of the proper arrangement and syntax?

Many thanks!

Difficult to know where to start, you have so much to learn from the sound of it.
I don’t have one of these but I have just looked at the data sheet.

First of all make up the circuit shown on page 5 of the data sheet.

Next you have to program your Arduino with the program on page 6. However you need to add the usual bits that I assume you are missing:-
#include <Wire.h>
void setup() {
Wire.begin(); // set up I2C
Wire.beginTransmission(0x09);// join I2C, talk to BlinkM 0x09
Wire.send(‘c’); // ‘c’ == fade to color
Wire.send(0xff); // value for red channel
Wire.send(0xc4); // value for blue channel
Wire.send(0x30); // value for green channel
Wire.endTransmission(); // leave I2C bus
}

void loop() {
}

Up load that to the Arduino and run it and you should see a change in the LED.

What you are doing is sending those numbers which represent commands and values to the BlinkM.

The next thing is to do stuff in the loop() section. Using those 6 lines but changing the numbers in them, put a delay(2000) between each group of six lines to allow two seconds so you can see things happen. Look at the data sheet to see what numbers do when you send them to the BlinkM.

Hope that gets you started.

Thanks, Mike,

Two questions right off. First, which "6 lines" do you mean?

Second, I have copied and pasted your example as is into the arduino sketch. I also added the BlinkM_funcs.h library. When I try to upload it to the arduino, I get an error message that says that I have a stray '\' command at the wire.send('c'); line. This is the syntax that is specified in the data sheet also...

Ok by the six lines I actually mean the last 6 lines that start "Wire." In other words don't use the Wire.begin(); again.

That other error is caused by the cut and paste software substituting inverted quotes for the single quote. The C should be surrounded by a single quote mark, on my keyboard (Mac) its under the double quotes.

Aha! Dat pesky cut and paste software! Okay, that works. Or at least it does something.

Next problem:

I tried including the BlinkM_nonvol_data.h library into a sketch and I get an error message asking for an initializer before PROGMEM. Anybody know what that should be or how to fix it? This is a library that is supposed to include preprogrammed light scripts, as described in their data sheet.

Thanks.