I want to send some test codes to a MIDI synthesizer, so I wrote a program that lets me just type in hex codes on the serial monitor and send it over serial as the byte value. For example typing "90 45 63" should turn on note 0x45 with a velocity of 0x63. This part works ok and I have the arduino hooked up to a midi connector and from there to a midi synth. I've verified that this works ok with some test code.

Where I'm having trouble is that MIDI requires a rather unorthodox baud rate of 31250. The problem is then that on an Arduino Uno, I don't see how I can enter serial data when the Arduino's serial monitor doesn't allow that baud rate. Also trying to set that baud rate under Linux using stty generates an "stty: invalid argument ‘31250’" error. So is there a way to use a different baud rate for input than for output or some other solution here? I do have a Teensy 3.1 with multiple Serial ports, but its kinda tied up at the moment and I just thought I could use an Uno for this.

UPDATE: It works now. Something to keep in mind when working with complex external components like a professional synthesizer. The Roland JV-880 that I'm interfacing with wasn't receiving program changes even though I was sending the 0xC0 0x03 codes or whatever. This is why I made this debugging program to begin with. After searching around and being stumped, I looked around the system settings on the synthesizer and discovered a setting called "System MIDI Rx switch Program change=OFF". After I changed that to ON the program change codes worked. Sometimes the problem is nothing in your code or circuit.

  • Have you considered using a MIDI port? Sep 5, 2016 at 15:12
  • @IgnacioVazquez-Abrams Sorry I should have mentioned. I have the arduino hooked up to a female midi connector and from that up to the midi port on a synthesizer. That aspect is working fine and I've been able to play notes using a simple test program.
    – deltaray
    Sep 5, 2016 at 15:24
  • So... do you then have two serial connections, one to the host and one MIDI? Sep 5, 2016 at 15:26
  • No, I was just using the TX (pin 1) on the arduino to send data over the midi port and then the usb connection to the computer. Maybe the serial port can't be shared like this?
    – deltaray
    Sep 5, 2016 at 15:27

1 Answer 1


The Arduino Uno is powered by an ATmega328P microcontroller. This microcontroller has only one UART which is not capable of using different baud rates for sending and receiving.

You could look into the different software serial port implementations for the sending side. Another solution would be to continually change the baud rate: each time you get a complete message from the serial monitor,

  • you switch the baud rate to 31250 bps
  • you send the packet to the midi synth
  • you Serial.flush() to make sure the bytes have actually been sent
  • you switch back the baud rate to whatever you used in the serial monitor

You will probably see some garbage on serial monitor as it receives the bytes at the wrong rate, but that should not be an issue.

  • Software serial! That's brilliant and was easier than I expected. So far it works fine, although its a bit slow to send the codes. Not sure why. But it works for my purposes. Thanks.
    – deltaray
    Sep 5, 2016 at 17:05
  • Well, I was actually thinking about the alternatives to SoftwareSerial, like AltSoftSerial (there are others). The standard SoftwareSerial is not very good, as it tends to block interrupts for too long. But if it works fine for you, then it's all that matters. Sep 5, 2016 at 17:27
  • I tried AltSoftSerial and it is about the same, but if I use stty to setup the serial and just write to it with echo "904540" > /dev/ttyACM0 its much faster. Instantaneous even. If I use the Arduino IDE serial console the messages take about half a second to arrive on the synth.
    – deltaray
    Sep 5, 2016 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.