Go Down

Topic: Sending Midi Commands to Synthesizer (Read 2194 times) previous topic - next topic


Hello everyone, I'm new to the Arduino world, but have scripting background with Unity3d and thought I try a hand at basic controller programming.  My end goal on this project is to make a simple drum set that is connected to a Yamaha ytp-200 synthesizer through midi to play the respective drum notes using an Arduino Uno:

As a test, I found this project with a simple script (step 6) I'm using to play piano notes in a loop but I cannot seem to have the notes played from the synthesizer; I do see the Tx LED on the board blinking as it should be sending a signal.  I currently only have the female midi out connector wired to the Arduino Uno board as shown in step 3 to send the signal via Serial.write command to the synthesizer.


A lot of the instructables I'm seeing seem to use a midi software on the computer to play notes based on signals sent from Arduinos.  I feel like the testing I am trying to do is simple, but I'm a little stuck on having the Arduino communicate with the synthesizer to play simple notes.  I was wondering if it is possible to have the Arduino Uno connected via midi cable to a Yamaha synthesizer and the noteOn/noteOff commands to the synthesizer to play the notes?  Is there something I'm overlooking?

Thank you!


Apr 09, 2018, 04:10 am Last Edit: Apr 09, 2018, 04:57 am by Grumpy_Mike
Is there something I'm overlooking?
Two things:-
1) Instructables are by and large crap, written by people who have an inflated idea of their own ability.

2) There are two types of USB device a host and a client. Typically your computer is a host and a MIDI device is a client. With USB you can only have a host communicate with a client, you can not connect two hosts or two clients together. A MIDI synthesizer and an Arduino are both clients so they can not be connected together. The basic plug and sockets try and prevent two clients being connected together.

Now you can get a shield for an Arduino that turns it into a host, called, not surprisingly, a "host shield" so first off you need one of these. Then you need a driver code which you might find on line.

However using a 5 pin MIDI out from an Arduino into a synthesizer is possible.

By the way an Arduino does not use scripts, they are interpreted, an Arduino uses programs, sometimes called a sketch, they are compiled.

EDIT It could be that your synthesizer will only respond to signals on MIDI channel 10. So change that line to:-
Code: [Select]
int noteON = 144+9;  // this is channel 10 as MIDI channel 1 is indicated by a zero


The synth in question is a keyboard, not a drum kit, so it probably receives on all channels, but if you want only drums, use channel 10. I've used a 5 pin DIN connector both on the microcontroller side and the synt, which is old enough to have the 5 pin DIN. No fuzz about host or slave.

But you need to study the Yamaha specs. It needs some midi message to be set to receiving midi and performing received midi. Or it might also have a switch for it. Or some key combo while powering on, to set it into the midi receiving mode.

If you ask for help and write 'u' instead of 'you' because you think it's convenient, I will write 'no' instead of 'yes'. For same reasons.


Using the menu in the keyboard and turn the "Local" to off. You will then get no sound from the keyboard but you will get sound from messages on the MIDI input.


Grumpy_Mike, thank you for looking at this, I have tried adjusting the code to have it transmit on channel 10 with no change.  I have also tried toggling the Local between on and off with no change.  I might have to look into the Host Shield after all, I guess I had hoped that the simplicity of the setup made sense enough to work.

Jonah_Ha, thank you for your thought, I do have a female 5 DIN connector wired to my board, I have quadruple-checked the wiring to be sure I have the correct pins lined up with the Arduino.  I already checked the manual to see if there were any specific commands or steps I need to take and it did not indicate anything.  I'll do some more research on other midi commands that may work.

Part of me is wondering if maybe it is faulty wiring?  Maybe I should try having the TX1 pin tested, or maybe rewiring a new 5 DIN connector, or maybe replacing the midi cable I have?

Thank you for taking the time to take a look at this post, I hope to have an update with progress in the near future.


Hope you have the right resistor in the DIN contact.

If you ask for help and write 'u' instead of 'you' because you think it's convenient, I will write 'no' instead of 'yes'. For same reasons.


I have also tried toggling the Local between on and off with no change.
That is the one you must do, forget about the channel for the moment.
It looks like their is faulty wiring. Check again which way round those two wires are on the DIN plug, swap them if necessary.
That resistor should be 220R with the colours red, red, brown.


Yes, despite what that idiot instructables says 5V should go through 220 ohms to pin 4 and the signal should be on pin 5. Check the numbering moulded into the plug itself.



Apr 15, 2018, 06:09 pm Last Edit: Apr 15, 2018, 06:57 pm by homebrewhero
Hello all, sorry for the late response, life am-I-right?

I double checked my wiring, I have it set so that pin 4 is conencted to the Arduino 5V with a 220k (red red brown) resistor, and pin 5 connected to TX1 pin, which i had a 220k ohm resistor connected through as well per the Arduino tutorial below.



I think your problem is faulty wiring. You see the wiring going to what you thing is the right place but something is not making contact. How about posting a picture of your wiring showing all the wires so we can follow them.


Apr 15, 2018, 07:48 pm Last Edit: Apr 15, 2018, 07:54 pm by homebrewhero
Here is the board.  Well, that did not work..


Apr 15, 2018, 07:54 pm Last Edit: Apr 15, 2018, 07:55 pm by homebrewhero
DIN is upside down, pin 4 is on your right, green to TX1, Pin 5 is Red to 5V with a 220k resistor.


Apr 15, 2018, 09:09 pm Last Edit: Apr 15, 2018, 09:13 pm by Grumpy_Mike
That resistor is a 220K resistor, that is one thousand times the value you need.

which i had a 220k ohm resistor connected through as well per the Arduino tutorial below.
Read that tutorial again, that is not the value of resistor they tell you to use.


Thank you Grump_Mike.  Not sure why I thought I saw the k in there..

Go Up