ArduinoMega MIDI over TRS to Korg NTS-1

Hello

I recently acquired a Korg NTS-1 synthesizer which does midi in through a 3.5mm TRS cable, and I am building a keyboard/sequencer to control it (because the ribbon keyboard isnt very good.

I am sending MIDI messages over Serial, and using the following wiring for the 3.5mm jack:

Tip - 220 ohm resistor - TX0 (digital pin 1)
Ring - 220 ohm resistor - 5V
Sleeve - GND
I used the info from these sites to figure this out:

https://www.arduino.cc/en/tutorial/midi
https://www.midi.org/articles-old/trs-specification-adopted-and-released (the picture at the top)

When I run my code and use Hairless Serial to MIDI on my computer (using Serial baud rate 115200), it shows that the messages are coming through fine.
However, when I try to connect it to the NTS-1 (using Serial baud rate 31250) I don't get any notes. I made sure the input channels matched and turned off Midi RX short message on the synth.

Here's my code (not finished, but it accomplishes what I need):

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

enum { //for modes
  MODE_INIT,
  MODE_PLAY,
  MODE_PROGRAM,
  MODE_ARP,
  MODE_KEYBOARD
} modes;

int currentMode = MODE_INIT;
int keyboard[] = {22, 36, 23, 37, 24, 25, 38, 26, 39, 27, 40, 28, 29, 41, 30, 42, 31, 32, 43, 33, 44, 34, 45 ,35};
String keys[] = {"C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B"};
byte currentKey; 
byte currentOctave = 4;
byte prevOctave;
boolean notesPlayed[24];
boolean prevNotesPlayed[24];

void updateNotes() {
  for (int i = 0; i < 24; i++) {
    prevNotesPlayed[i] = notesPlayed[i];
  }
  for (int i = 0; i < 24; i++) {
    if (digitalRead(keyboard[i]) == HIGH) {
      notesPlayed[i] = true;
    } else {
      notesPlayed[i] = false;
    }
  }
}

void noteOn(int note) {
  Serial.write(0x90);
  Serial.write(note);
  Serial.write(0x7F);
}

void noteOff(int note) {
  Serial.write(0x90);
  Serial.write(note);
  Serial.write(0x00);
}

void allNotesOff() {
  Serial.write(0xB0);
  Serial.write(123);
  Serial.write(0);
}

void setup() {
  // put your setup code here, to run once:
  pinMode(9, INPUT);
  pinMode(8, INPUT);
  for (int i = 22; i <= 45; i++) {
    pinMode(i, INPUT);
  }
  lcd.begin(20, 4);
  //MIDI.begin(MIDI_CHANNEL_OMNI);
  lcd.setCursor(0, 2);
  if (digitalRead(8) == HIGH) {
    Serial.begin(115200);
    lcd.print("baud 115200");
  } else {
    Serial.begin(31250);
    lcd.print("baud 31250");
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  switch (currentMode) {
    case MODE_INIT:
      lcd.setCursor(0,0);
      lcd.print("Arduino Sequencer");
      lcd.setCursor(0,1);
      lcd.print("v. 1.0");
      delay(500);
      lcd.clear();
      currentMode = MODE_KEYBOARD;
      break;
    
    case MODE_KEYBOARD:
      lcd.setCursor(0,0);
      lcd.print("Keyboard mode");
      lcd.setCursor(0, 1);
      lcd.print("Octave: " + String(currentOctave));
      prevOctave = currentOctave;
      currentOctave = map(analogRead(A0), 0, 1023, 6, 1);
      int cursorCount = 0;
      for (int i = 0; i < 24; i++) {
        if (notesPlayed[i] && !prevNotesPlayed[i]) {
          noteOn((currentOctave + 1) * 12 + i);
          delay(50);
        } else if (!notesPlayed[i] && prevNotesPlayed[i]) {
          noteOff((currentOctave + 1) * 12 + i);
          delay(50);
        }
      }
      if (digitalRead(8) == HIGH) {
        lcd.clear();
        currentMode = MODE_ARP;
      }
      break;
      
    case MODE_ARP:
      currentKey = map(analogRead(A0), 0, 1023, 0, 11);
      
  }
  updateNotes();
}


Also here's the NTS-1 midi spec in case it helps

You could try swapping over the signals to the tip and ring.

So I tried that and it still didn't work at first, but after fiddling with the synth configuration and looking at some more documentation I figured out that it actually worked the way I had first wired it. The problem was in my synth configuration, not my code or the wiring

Thanks for the help