Arduino MIDI controller

Alright, i have an Arduino Leonardo and I want to make a Arduino MIDI controller
because I need one, but I can't get it to work. I've downloaded some software and it works with the two pots i have. I also have a small keyboard that I want to use and it has a MIDI out, and I'm trying to send the serial data form the MIDI over the arduino to the PC (to the software that will later on turn this data into midi data that i can use with FL Studio or other programs) but it won't work. Now, this is the circuit tha I've came up with by using the parts that i have and by referencing other similar projects that I found on the web and the the code I wrote for it. Can someone explain me what's wrong with either one of them??

#include <SoftwareSerial.h>


//Analog pin ZERO
int valuePinZero=0;
int valuePinZero2=0;
 
//Analog pin ONE
int valuePinOne=0;
int valuePinOne2=0;
 
//Analog pin TWO
int valuePinTwo=0;
int valuePinTwo2=0;

byte commandByte;
byte noteByte;
byte velocityByte;

SoftwareSerial MIDIout(12,13);

void setup(){
  MIDIout.begin(31250);
  Serial.begin(31250);
  while(!Serial){
    ;
  }
}



    

void loop(){
  checkMIDI();
  
  
  
  
valuePinZero = (analogRead(0)/8); 
if (valuePinZero-valuePinZero2 >=2 || valuePinZero2-valuePinZero >=2) { 
valuePinZero2 = valuePinZero; 
 
MIDI_TX(176,75, valuePinZero); 
//delay(100); //pour le debuggage
}
 

//————————
valuePinOne = (analogRead(1)/8);
if (valuePinOne - valuePinOne2 >=2 || valuePinOne2 - valuePinOne >=2)
{
 
valuePinOne2 = valuePinOne;
 
MIDI_TX(176,76, valuePinOne);
//delay(100);
}
 

//————————
valuePinTwo = (analogRead(2)/8);
if (valuePinTwo - valuePinTwo2 >=2 || valuePinTwo2 - valuePinTwo >=2)
{
 
valuePinTwo2 = valuePinTwo;
 
MIDI_TX(176,77, valuePinTwo);
//delay(100);
}
}

void MIDI_TX(unsigned char MESSAGE, unsigned char DONNEE1, unsigned char DONNEE2) 
{
 Serial.write(MESSAGE); 
 Serial.write(DONNEE1); 
 Serial.write(DONNEE2); 
}

void checkMIDI(){
  do{
    if (MIDIout.available()){
      commandByte = MIDIout.read();//read first byte
      noteByte = MIDIout.read();//read next byte
      velocityByte = MIDIout.read();//read final byte
      Serial.write(commandByte);
      Serial.write(noteByte);
      Serial.write(velocityByte);
      
    }
  }
  while (MIDIout.available() > 2);//when at least three bytes available

}

I've never used MIDI so I didn't bother looking at your code.

You've got the wrong type of opto-isolator. The one you have is for driving a TRIAC at 120 or 220VAC (to make a light dimmer, etc.).

And, it's wired wrong on the Arduino side. One pin needs to go to ground. The other pin goes to a 5V pull-up resistor, and the junction between the resistor and opto-isolator goes to the Arduino input. I found a little schematic [u]here[/u].

Or, you can configure the internal pull-up resistor. The pull-up pulls the input high when the opto-isolator is off. When the opto-isolator is on (conducting), it pulls the input low.

And if you are using pin 13 as an input, make sure it's configured as an input. "Traditionally" pin 13 is used as an output since it has an LED attached.

I also have a small keyboard that I want to use and it has a MIDI out

If your keyboard has a MIDI output through USB then you can only receive information from it if you have a Host shield on your arduino.

That circuit as well as being wrong like DVDdoug told you is also wrong in concept. Opto isolators are only used on MIDI inputs not outputs. Rip the whole thing up and tryt again.
This might help you:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Shield.html

Thanks for the reply.