Scripting the BlinkM
I just started working with the BlinkM and Arduino Diecimila. I'm trying to program up the BlinkM to fade randomly from one color to another, looping until I cut the power to the BlinkM.
I started off with the example "Programming Light Scripts" from the BlinkM datasheet. This apparently is full of mistakes. I fixed it, I think, see bellow:
#include "Wire.h"
#include "BlinkM_funcs.h"
void setup(){
blinkm_script_line script_lines[] = {
{ 1, {'f', 20,0x00,0x00}}, // set fade speed to 1
{ 1, {'C', 0xff,0xff,0xff}}, // randomly alter
};
byte addr = 0x09;
byte script_id = 0; // can only write to script 0
byte script_len = 2; // number of lines in script
byte script_rep = 20;
BlinkM_beginWithPower();
BlinkM_writeScript(addr, script_id, script_len, script_rep, script_lines);
}
void loop(){}
Now, I think, this is supposed to get the BlinkM to set the scrip to randomly fade colors but I'm just getting the default blink pattern.
Any ideas?
Thanks - AYAL
I started off with the example "Programming Light Scripts" from the BlinkM datasheet. This apparently is full of mistakes. I fixed it, I think, see bellow:
#include "Wire.h"
#include "BlinkM_funcs.h"
void setup(){
blinkm_script_line script_lines[] = {
{ 1, {'f', 20,0x00,0x00}}, // set fade speed to 1
{ 1, {'C', 0xff,0xff,0xff}}, // randomly alter
};
byte addr = 0x09;
byte script_id = 0; // can only write to script 0
byte script_len = 2; // number of lines in script
byte script_rep = 20;
BlinkM_beginWithPower();
BlinkM_writeScript(addr, script_id, script_len, script_rep, script_lines);
}
void loop(){}
Now, I think, this is supposed to get the BlinkM to set the scrip to randomly fade colors but I'm just getting the default blink pattern.
Any ideas?
Thanks - AYAL
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Hi,
It looks like your close. You might want to check your BlinkM ID, the default unless you have specifically programmed it is 0x10. (you can use the BlinkM_checkAddress command for a quick sanity check to make sure your communicating) or if your lazy just do a quick color set or fade during your init so you can visually see your actually talking to the BlinkM and not just providing it power.
You have programmed the script 0, but it doesn't appear you have started the script running.
You can call:
BlinkM_playScript( addr, 0,0,0 );
to repeat script 0 forever.
If you want your script to run by default on power on for battery operation check out the "Set Startup Parameters" command to boot with a specific script number and play parameters.
Hope this helps,
Will
ps. if the random color swings are too drastic for you don't forget you can specifiy a smaller value for the parameters of your random call in the script.
{'C', 0x15,0x15,0x15} for example.
Have fun! -
Inappropriate?Will -
Thanks for your reply. That helps. I actually got the 0x09 address from the BlinkM datasheet, seems like it might be time to update the datasheet.
I'm wondering if my problem is more basic.I'm a real newbie to the whole Arduino environment so perhaps I need some very simple step by step instructions.
- I've plugged in the Arduino board, via USB
- I've run the Arduino 0011 development environment
- I've uploaded the BlinkMCommunicator code to the board
- I've unplugged the Arduino board, plugged in the BlinkM, and plugged the Arduino back in
- I've restarted the Arduino 0011 development environment and opened my sketchbook with the example code above.
Now what? The only options I seem to have in the Arduino development environment is to 'Verify' the code or 'Upload to the I/O board'. Uploading to the I/O board doesn't seem to do it.
Again, thanks for the help - AYAL
I’m confused
-
Inappropriate?Hi,
Your correct 0x09 is the default (sorry i shouldn't be typing at 3am..) Some of the BlinkM example projects allow the id to be changed, so if you have done that like I did then try just a few lines of sample code without setting or checking the address it could be mismatched.
In the Arduino IDE there should be another button available to you. On the row of buttons just below the file menu try the one all the way on the right. It is the "Serial Monitor" If you set the baud rate to match the speed the sketch has programmed the Arduino to communicate with (19200 in the case of te BlinkMCommunicator code) you should be seeing text coming back from the Arduino window of the IDE, via the sketches "Serial.print functions. You can then send text or commands in the small text box by typing and pressing send.
To verify your communicating with your Arduino correctly you might try running the Sketchbook->Examples->Digital->Blink sketch. The leds should be quickly flashing during the sketch upload and then the led near pin 13 should continue to flash on/off.
Good luck,
Will -
Inappropriate?Thanks, Will. You're definitely on the right track. Assuming you've run the "BlinkMTester" Arduino sketch, your BlinkMs address got changed to 0x10. The default BlinkM address is 0x09 but BlinkMTester sets the address to 0x10 when it's run.
I admit that I probably confused things with BlinkMTester rewriting the address. All the other examples either assume 0x09 or explicitly set the address back to 0x09. Apologies for the confusion.
I've updated the BlinkM_Examples.zip bundle so that BlinkMTester resets the address to 0x09. I also added your example above as "BlinkMScriptWriter2". You can also browse the examples.
In general, any time you think you're having problems with a BlinkM, use BlinkMTester or BlinkMMulti (or equivalent) to reset the address to a known value. Alternately, send it commands with address 0 (the broadcast or "general call" address), which all BlinkMs on the I2C bus will respond to.
1 person says
this answers the question
Loading Profile...




EMPLOYEE