Receive MIDI via DIN midi cabling and display on serial monitor using UNO

Hi everyone,

My goal is to properly receive, store and print a simple MIDI messages.

Put simply:

  • Hit one key of midi-keyboard
  • receive all midi messages (status and data bytes)
  • store the values in a variable
  • display the values on the serial monitor (each byte in decimal data type).

My midi-keyboard is connected to the Arduino Uno via DIN midi cable (receive only). I used the exact schematics provided by Amanda Ghassaei (retrieved from instructables -> Step 10). Receiving messages seem to work as the internal LED flashes whenever the note "Middle C" is hit.

My problem:

  • The received bytes are not displayed properly using the following code 1 (see picture attached)
  • If I use code 2, four bytes are received and displayed in correct (decimal) format but it seems to be the wrong bit-sequences each time.

I would be grateful for a hint about altering the code or thinking in a different direction as my programming skills are very limited :frowning:

It seems to me that receiving data on a serial port at 31250baud does not go along with using serial monitor which I cannot configure to use the same baud-rate.

Also, if I overlooked a thread that solved my issue --> My apologies, please drop me a link.

Thank you very much for your tips and time to stop by and studying my problem.

KR, hobbes02

The Arduino UNO only has a single hardware UART. Pins 0 and 1 are connected to the Serial-to-USB adapter internally.
You can only use the UART for one thing at a time, either to send data to the computer over USB, or to send and receive MIDI.

Other boards have multiple UARTs (e.g. Mega or Nano Every) or a UART and a native USB connection (e.g. Nano or Micro), and would be much better suited for a project like yours.

That being said, you could try moving the MIDI interface to a SoftwareSerial port, but chances are you'll run into timing issues, it's sort of a hack.

Please never post pictures of text. Post text (using [code][/code] tags).

Pieter

Dear Pieter,

that makes perfect sense. Thank you for your quick reply. I ordered a Mega to be more flexible from now on. 'hope that this already achieves my goal.

Thanks again.