I need some basic programming advice on my project. I'm driving maxm rgb led modules with midi from ableton live. I want to be able to control the color (hue) with the note intensity value, the saturation with the channel volume control change and the value with the channel control n°14. For now, when one of this message is received, the BlinkM_fadeToHSB() is called with the changed parameters. The problem is I can't get led's off with the intensity at 1 because the other functions are still called by the other functions fadeToHSB called. How can I manage this better?

Second short question, my midi data values are from 1 to 127 and I would like to transform them from 0 to 255 with artificial +1 increments, is there an elegant way to do that?

Last one, due to the midi specific baud rate, I can't get the serial monitor working to have a look at my variables or midi in messages. Is there a workaround for that?

// Below is my function that will be called by the Midi Library// when a MIDI NOTE ON message is received.// It will be passed bytes for Channel, Pitch, and Velocityvoid MyHandleNoteOn(byte channel, byte pitch, byte velocity) { digitalWrite(LED,HIGH); //Turn LED on if (velocity == 1) {//A NOTE ON message with a velocity = 1is actualy a NOTE OFF digitalWrite(LED,LOW);//Turn LED off BlinkM_fadeToHSB(blinkm_addr, 0, 0, 0); } color = velocity*2+1; BlinkM_fadeToHSB(blinkm_addr, color, saturation, intensity);}

That is because you can't specify other pins for debugging.You could use software serial and then build a TTL to RS232 converter. Then use a USB to RS232 lead and another serial monitor like putty,, but that is complex.

Transforming 1 to 127 into 0 to 255 can be done with the map function.

My code is a bit better now, the map function work perfectly, thanks! I still can't figure out how to interrupt the leds when I receive a note at velocity>1. I've tried many different scheme but nothing works. Maybe it's more a midi than LED problem...Here is a version with a boolean between the two callbacks.

// Below is my function that will be called by the Midi Library// when a MIDI NOTE ON message is received.// It will be passed bytes for Channel, Pitch, and Velocityvoid MyHandleNoteOn(byte channel, byte pitch, byte velocity) { digitalWrite(LED,HIGH); //Turn LED on if (velocity == 1) {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF digitalWrite(LED,LOW);//Turn LED off oklight = false; } if (velocity > 1) { oklight = true; } }

pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.// OMNI sets it to listen to all channels.. MIDI.begin(2) would set it// to respond to channel 2 notes only.

MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command // tells the Midi Library which function I want called when a Note ON command // is received. in this case it's "MyHandleNoteOn". MIDI.setHandleControlChange (HandleControlChange);

}

void loop() { // Main loop MIDI.read(); // Continually check what Midi Commands have been received

still can't figure out how to interrupt the leds when I receive a note at velocity>1

This is because you are using those built in functions to control your LEDs. These functions do not return until the fading is compleate. To get over this you will have to code this yourself in an interruptable fashion along the lines of the blink without delay sketch.

well I though I could find a way to have one instance of the builtin function in the loop() and sending paramaters from the callbacks but that doesn't work or I'm doing it wrong. I've change the fade time to "instantaneous" so these functions returns quite fast, maybe a wait(1) could be the solution.

// Below is my function that will be called by the Midi Library// when a MIDI NOTE ON message is received.// It will be passed bytes for Channel, Pitch, and Velocityvoid MyHandleNoteOn(byte channel, byte pitch, byte velocity) { digitalWrite(LED,HIGH); //Turn LED on if (velocity == 1) {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF //BlinkM_fadeToHSB(blinkm_addr, 0, 0, 0); } if (velocity > 1) { //color = map(velocity, 1, 127, 0, 255); } }

pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.// OMNI sets it to listen to all channels.. MIDI.begin(2) would set it// to respond to channel 2 notes only.

MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command // tells the Midi Library which function I want called when a Note ON command // is received. in this case it's "MyHandleNoteOn". MIDI.setHandleControlChange (HandleControlChange);

}

void loop() { // Main loop MIDI.read(); // Continually check what Midi Commands have been received

So I've added two boolean "tokens" between the midiNoteOn and midiControlChange callbacks and it works! It thus wait the return of the function before being able to lauch a new transmission. Not sure it's the most elegant wait to do it but as for now it's a good start.

// Below is my function that will be called by the Midi Library// when a MIDI NOTE ON message is received.// It will be passed bytes for Channel, Pitch, and Velocityvoid MyHandleNoteOn(byte channel, byte pitch, byte velocity) { digitalWrite(LED,HIGH); //Turn LED on if (velocity == 1) {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF digitalWrite(LED,LOW);//Turn LED off

pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.// OMNI sets it to listen to all channels.. MIDI.begin(2) would set it// to respond to channel 2 notes only.

MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command // tells the Midi Library which function I want called when a Note ON command // is received. in this case it's "MyHandleNoteOn". MIDI.setHandleControlChange (HandleControlChange);