How to debug MIDI input? I'm trying to receive MIDI messages on a Leonardo. To do that I used the circuit in the diagram below (only the top half for receiving). The only thing I did differently was using an 1N4148 diode instead of the 1N914. I connected GND to pin GND, 5V to pin 5V and RX to pin 0 (RX), and I used code below to see whether I do get any inputs or not. (I first started with some more complex code but it seems this is the minimal thing I can do.) As a MIDI source I used an Arturia Keystep which I tested on a midi instrument.

Unfortunately I don't get any input, and I don't know why. What I tried so far:


Verified the polarity of all cables, and made sure all connections work.
Swapped the Leonardo with a different one (both new).
Swapped out the 6N137 optocoupler with another one (both new).
Addded above the if-statement a Serial.println("test"); which then resulted in an endless avalanche of "test" in the serial monitor - just to check if the USB connection works.
Measured the voltage between pin 5 and 8 on the 6N137 and it is indeed 5V.


Is there anything obvious I'm doing wrong? What things do you suggest doing to try to find the bug? (I do have a multimeter but no oscilloscope.)

 (from this answer).

byte b;
void setup() {
  Serial.begin(9600); //USB
  Serial1.begin(31250); //MIDI
}

void loop() {
  if (Serial1.available() &gt; 0) {
    b = Serial1.read();
    Serial.println((int)b);
  }
}
The solution:
On the image is stated plugs are solder-side. So swapping pin 2/3 does the trick