Midi library and debugging using serial terminal

Hi Guys,
so I am trying to output midi data when buttons are pressed that are part of a button array. The button array works fine, its just the midi stuff that im not sure of.
Im using MIDI.h and a different serial terminal that I can specify 31250 baud rate, however I don't know whether the data coming through is correct.
In my main loop I have the following code reading the current state of the buttons:

    for (int c=0; c<COLS; c++) {
    pinMode(colPins[c],OUTPUT);               // Prepare column pin for sending a pulse.
    digitalWrite(colPins[c], LOW);            // Pulse the pin colPins[c] low.
    for (int r=0; r<ROWS; r++) {
      if (!digitalRead(rowPins[r])){          // A key is PRESSED on row r, column c
        buttonstate[r][c] = 1;            // Store PRESSED keys.
        MIDI.sendNoteOn(42,127,1);

      }
      else {
        buttonstate[r][c] = 0;            // Store OPEN keys.
        MIDI.sendNoteOff(42,0,1);
      }

    }


    digitalWrite(colPins[c], HIGH);          // End the pulse
    pinMode(colPins[c],INPUT);	         // Prevent shorts between columns when multiple keys are pressed.
  }

Is that how I am supposed to use this midi library? Can you debug midi data through a terminal?

Can you debug midi data through a terminal?

Certainly.

You can print the same values being sent to the MIDI.SendNoteOn() method.

So this is the kind of thing I get:

[00][00]€*[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00]€[00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00][00]*

this is my code:

#include <MIDI.h>
void setup()
{ 
  MIDI.begin();
  for (byte r=0; r<ROWS; r++) {
    pinMode(rowPins[r],INPUT);
    digitalWrite(rowPins[r],HIGH);	// Enable the internal 20K pullup resistors.
  }

} 


void loop() {
   readValues();

}

void readValues()
{
  sendValues();
  for (int c=0; c<COLS; c++) {
    pinMode(colPins[c],OUTPUT);               // Prepare column pin for sending a pulse.
    digitalWrite(colPins[c], LOW);            // Pulse the pin colPins[c] low.
    for (int r=0; r<ROWS; r++) {
      if (!digitalRead(rowPins[r])){          // A key is PRESSED on row r, column c
        buttonstate[r][c] = 1;            // Store PRESSED keys.
        MIDI.sendNoteOn(42,127,1);

      }
      else {
        buttonstate[r][c] = 0;            // Store OPEN keys.
        MIDI.sendNoteOff(42,0,1);
      }

    }

I have left out the declaration of variables, but it compiles and runs. I am using termite set at 31250 (baudrate) and the above is the output, there seems to be some sort of correlation as to when the € appear and me pressing a button but it doesnt seem like a "code" as such - i.e something as to what I imagined midi would "look" like...

   readValues();

There is NOTHING in this function name that suggests that it is going to do this:

  sendValues();

Either rename the function or get rid of this call in this function.

I have left out the declaration of variables

Along with the code that prints the values.

but it compiles and runs.

Well, then, it must be perfect. What is your problem, then?

Sorry that function name is a relic. I do need to change that before things get complicated!
So maybe i Am missing the point? i thought because I am using the
MIDI.sendNoteOn(42,127,1);

command that would deal with writing to the serial - Otherwise where is it outputting to?
There is no code that prints the values in other words. I thought my serial terminal could just pick up the output of MIDI.sendNoteOn?

I thought my serial terminal could just pick up the output of MIDI.sendNoteOn?

Perhaps you should look at the sendNoteOn() and sendNoteOff() methods in the MIDI class, and see just how it combines those three arguments and how it writes the result(s) to the serial port.

So after looking at it, when you call a method such as sendNoteOn, that in turn calls Send.
Send writes single bytes to the serial port at 31250 baud rate.
That seems fine to me, so why does it come out as complete jargon? Because its bytes?

EDIT:
Alright, Ive got it to work.
Do I have to SendNoteOff if a button is not pressed? Does anyone know of a good serial to midi application? I have tried Spreckenzielab, but when I close it, my computer bluescreens... Really annoying.

      if (!digitalRead(rowPins[r])){          // A key is PRESSED on row r, column c
        buttonstate[r][c] = 1;            // Store PRESSED keys.

        MIDI.sendNoteOn(42,127,1);  // Send a Note (pitch 42, velo 127 on channel 1)

      }
      else {
        buttonstate[r][c] = 0;            // Store OPEN keys.
        //MIDI.sendNoteOff(42,127,1);; ---This line. Is it needed????

      }