How can I control a BlinkM from a PC via Processing?
Here's what I'm trying to do: I loaded the BlinkMCommunicator sketch on the Arduino board, then close the Arduino IDE and connect the BlinkM to Arduino board (success).
Then, I move to the Processing IDE. I'd like to write a sketch in Processing to control the BlinkM from the computer. For example, if I press a key on the keyboard, the Processing sketch picks up the key press and triggers a color change on the BlinkM. Or, the Processing sketch is retrieves a value from a website and based on that changes the color on the BlinkM.
The Arduino board is tethered to the computer by a USB cable, and the BlinkM is connected to the Arduino board.
Sorry, if I'm being dense and missing something obvious. The two Processing sketches in the examples both use a JAVA GUI app as helpers to load scripts. I don't want to deal with the JAVA GUI. I just want to send command changes to the BlinkM directly from the Processing sketch.
Then, I move to the Processing IDE. I'd like to write a sketch in Processing to control the BlinkM from the computer. For example, if I press a key on the keyboard, the Processing sketch picks up the key press and triggers a color change on the BlinkM. Or, the Processing sketch is retrieves a value from a website and based on that changes the color on the BlinkM.
The Arduino board is tethered to the computer by a USB cable, and the BlinkM is connected to the Arduino board.
Sorry, if I'm being dense and missing something obvious. The two Processing sketches in the examples both use a JAVA GUI app as helpers to load scripts. I don't want to deal with the JAVA GUI. I just want to send command changes to the BlinkM directly from the Processing sketch.
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?In Processing, you connect with the Serial library to an Arduino running the BlinkMCommunicator sketch. At the top of the sketch file of BlinkMCommunicator is a description of the data format used by Processing sketches (or other programs) that want to send commands to BlinkM. The Processing applications BlinkMSequencer and BlinkMScriptTool are fairly detailed examples of how to use Processing with a BlinkM. Both use a Java/Processing class called "BlinkMComm.pde" that contains all the low-level stuff.
For something simpler, you can directly connect to the serial port the Arduino is on and send data to it by hand. Below is a snippet from small Processing sketch called "BlinkMTinyToy" that does that. It lets you change the BlinkM's color and play the first 10 light scripts built into BlinkM.
The entire sketch is here: BlinkMTinyToy.pde
Here's what it looks like when running:
/**
* Send an I2C command to addr, via the BlinkMCommunicator Arduino sketch
* Byte array must be correct length
* For details on the format of the data to send to BlinkMCommunicator,
* See to top of the BlinkMCommunicator sketch
*/
public synchronized void sendCommand( byte addr, byte[] cmd ) {
println("sendCommand: "+(char)cmd[0]);
byte cmdfull[] = new byte[4+cmd.length];
cmdfull[0] = 0x01; // sync byte
cmdfull[1] = addr; // i2c addr
cmdfull[2] = (byte)cmd.length; // this many bytes to send
cmdfull[3] = 0x00; // this many bytes to receive
for( int i=0; i<cmd.length; i++) { // and actual command
cmdfull[4+i] = cmd[i];
}
port.write(cmdfull);
}
// a common task, fade to an rgb color
public void fadeToColor( int r, int g, int b ) {
byte[] cmd = {'c', (byte)r, (byte)g, (byte)b};
sendCommand( blinkmAddr, cmd );
}
// in use it would look like:
// turn blinkm green
fadeToColor( 0, 255, 0 );
1 person says
this answers the question
Loading Profile...



EMPLOYEE