works: MIDI-IN: code + schematics

Hello there,

I have a big problem. I made the whole schematic, exactely as described in the post above. But it still fails to work.

I want to make about 36 LED's, corresponding to the midi output of my electronical keyboard.
This means that by playing the middle C, the first LED switches on. By pressing the C#, the second, and so on.

When letting the tone go, the LED should switch off.

This is a very important project for my school. Could somebody help me out?

I tried all the comments posted on this forum.
This is the code I used to debug the system.
Even this didn't work.

Another question I have is the following:
How can I tell the difference between pin number 4 and 5.
When looking at the front side of the plug, is it a fact that the left pin is always number 5?

I hope to receive a usefull reply!

Andreas Viruly from the Netherlands

byte incomingByte;
byte note=0;
byte velocity;
int statusLed = 13;   // select the pin for the LED
int action=2; //0 =note off ; 1=note on ; 2= nada

void setup() 
{
  pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  Serial.begin(31250);       
  digitalWrite(statusLed,HIGH); 
}

void loop ()
{
  if (Serial.available() > 0) 
  {
    incomingByte = Serial.read();

    if (incomingByte== 144)
    { // note on 
      action=1;
    }
    else if (incomingByte== 128)
    { // note off 
      action=0;
    }
    else if ( (action==0)&&(note==0) )
    { // if we received a "note off", we wait for which note (databyte)
      note=incomingByte;
      playNote();
      note=0;
      velocity=0;
      action=2;
    }
    else if ( (action==1)&&(note==0) )
    { // if we received a "note on", we wait for the note (databyte)
      note=incomingByte;
    }
    else if ( (action==1)&&(note!=0) )
    { // ...and then the velocity
      playNote();
      note=0;
      velocity=0;
      action=0;
    }
    else
    {
      //nada
    }
  }
}

void playNote()
{
  digitalWrite(statusLed, LOW);
  delay(1000);
  digitalWrite(statusLed, HIGH);
}