Go Down

Topic: Receiving MIDI Signals (Read 2 times) previous topic - next topic


It's libraries again, I have no idea what lc.setLed() does with its parameters, especially as the first one is always zero. 
By the way there is no need to do the two stage approach, setting an array and then transferring it into your library functions, just use the lc.setLed() function directly in the place where you set an array at the moment.

(or noteOn with velocity <10) sets the value to 0.

acording to the MIDI standard it should be:-
noteOn with velocity == 10 sets the value to 0.


Yes fair enough. That library controls the max7219 that runs the matrix.
Code: [Select]

lc.setLed(int deviceID, int col, int row, boolean isOn);

And good point about not needing the array. That's just habbit from the last project. To put this in context, I have wired up a LED matrix ( as shown here http://arduino.cc/playground/Main/LedControl as a set of Christmas lights for my tree. I currently have them doing various effects and flashing along to a few Christmas carols but I thought why not go all out and put those hours I spent as a child learning Christmas carols to good use and sync it up with my keyboard.

I'll sleep on it and tackle this again after work tomorrow.

Thank you for you help


If you want to continue to use the MIDI library, you can simplify your code a lot by using the event handlers. To do that, in your setup function:
Code: [Select]
  // Initiate MIDI communications, listen to all channels, turn off thru mode
  // By default, the MIDI library sends everything THRU. We do NOT want that!

  // Connect MIDI status changes involving a channel to handlers

Then, create a function for handling note on and note off:

Code: [Select]
void HandleNoteOn(byte channel, byte pitch, byte velocity) {
// check your pitch, velocity, and channel here
// turn on the LED matching pitch
void HandleNoteOff(byte channel, byte pitch, byte velocity) {
// check your pitch, velocity, and channel here
  // turn off the LED matching pitch

Now your loop function is simple:
Code: [Select]

void loop() {


Hi mymeastro,

Thanks for the post. I tried it that way and it is working much better. Its still not fast enough to keep up with me playing though.

I'm gonna break this down and start from scratch as Im on holidays for 2 weeks in 2 days. Well not from scratch, just simplify the project a little and try to control a couple of LED's like in the original post I looked at. That way I can test the MIDI interface and code a little more accurately rather than stuffing around with the matrix.


You don't need to refresh the entire grid each time!
Just change the specific LED that relates to the MIDI note. The 7219 will take care of the rest.

Go Up