Introduction: MIDI TO ARDUINO

This is already part of some of my Instructables, but probably hard to find via the search function.

It is used in the following Instructables:

Micro Timelapse Dolly with DC motors:

https://www.instructables.com/id/MICRO-ARDUINO-GOPR...

The advanced Micro Timelapse Dolly with cheap steppers:

https://www.instructables.com/id/MICRO-MIDI-STEPPER...

The cable dolly project:

https://www.instructables.com/id/ARDUINO-FOUR-LINE-...


The fritzing is pretty much self explaning, you can use any arduino you want.
Be sure to unplug the line to the TX pin on the arduino while uploading programs, i made a small button that i press while uploading on my midi shield.

Step 1: PARTSLIST

1x 5pin DIN/MIDI socket

1x 4n35 optocoupler or matching type

1x diode, or matching type

1x 220 Ohms resistor

1x 560 Ohms resistor (i used a 220 and a 330 in series and it worked)

1x bread or stripboard, as you prefer

1x Arduino (clone) obviously

1x MIDI cable

1x a MIDI source, the shield will work with ever device that sends MIDI protocol

Step 2: THE CIRCUIT

Its pretty easy to connect, depending on the type of board and MIDI-plug you got, you have to solder wires to it.

Make sure the diode is in the correct direction.

What the circuit does is decoupling the MIDI line from the Arduino.
The reason why you have to do this, is because the device that sends the MIDI signal, for example a keyboard, also "powers" the MIDI communication.
That means that it provides the 5V that "are" the MIDI signal.

If you would connect the MIDI plug with your Arduino directly you would most possibly kill the Arduino Input Pin, especially if there is some faulty wireing in the keyboard or sequencer you use.

As the name implies, the optocoupler is coupling by light, and therefore the MIDI host and the Arduino are not connected electrically.


Mechanically its a small LED and a photoresistor that has (nearly) no resistance when its exposed to light, and a very high resistance when its in the dark.
So everytime the MIDI host sends a HI the lamp flashes on, the resistor is no resistor anymore, and the arduino gets a HI on the inpout too.

The diode in the circtuit protects everything against false polarity.

This all is based on the MIDI standard, and the original schematic can be found here: http://www.midi.org/techspecs/electrispec.php

Step 3: THE CODE

This is the basic MIDI CALLBACK script.

It checks if a NoteOn is coming in and then jumps to the position in the script.
On this position you can put your code in, like read the velocity of that note and map it to a servo motor.

Step 4: THE POSSIBILITIES

As MIDI can be automated in DAWs and this MIDI tracks can be saved with your projects,The main possibilities i saw in this project are audio related.

To name a few:

Automated Microphone Stand.

Imagine re-amping, with a remote controlable microphone stand, saveable with your projects.

Automated Microphone Stand in a

Same Idea taken a bit further

Acoustic Drum Machine

Servos, Motors, a drumkit, a pair of spoons, an experimental acousic drum machine

Everything Timelapse related

As MIDI sequencers put out values in a 16/16 grid, and you can control and sync the tempo, its ideal for timelapse.
Also easy speedramping would be an option.



Comments

author
Stroopalini made it! (author)2017-05-14

I'm confused by the diagrams.

In the breadboard diagram, you
show PIN 4 going to ground, PIN 5 going to RX on the Arduino as well as
to 5v through a resistor, and nothing on PIN 6.

But in the
schematic, it looks like PIN 4 goes to RX on the Arduino as well as to
5v through a resistor, PIN 5 going to ground, and PIN 6 to 5v.

Do
PINs 4 and 5 happen to be reverse labeled on the schematic? And maybe
PIN 6 is only needed if implementing a MIDI Through jack?

author
ayhankaplan made it! (author)2017-03-31

Thanks for this!

I would like to know with what did you model the picture on the top?

author

its made with a free software called fritzing.

http://fritzing.org

author
franciscog34 made it! (author)2017-02-10

Hello dear, I would like to know if there is any way to go through the midi port in receiving the messages of edrums, add messages of electrical piezo and all send it to the port midi out.

The intention is to make a trigger for edrums.

author

ok, sorry, i just saw this is the midi-out tutorial.

well if you want to input analog values and output midi messages, this is the wrong tutorial.

This tutorial is about reading midi messages to output values

author

Hi, yes i guess so.

To read signals off of piezos or edrums/triggers you would need a way to read as much analog values as you plan to include drum pads.

I think you would also need an optocoupler or some way to protect the analog ins from to much current.

author
EnesY4 made it! (author)2017-02-27

I have a error bij MIDI.read();

author
RobB163 made it! (author)RobB1632017-03-14

add this under include midi.h

MIDI_CREATE_DEFAULT_INSTANCE();

author

Hi can you copy the error message so i can take a look at it?

author
R Jordan Kreindler made it! (author)2016-07-11

Nice job!

author

thanks! :)

author
snoop911 made it! (author)2015-02-27

Do you have any thoughts on Cycling74's Max software? It seems to be geared for Arduino / Midi Instruments, but not sure if it's worth checking out.

author

Ah ok "the" MAX :) didnt know the company is called cycling74 :)

but i dont see how midi should fit in, i use MIDI to control the arduino, i guess MAX uses USB. My main idea was to control a microphone stand via midi from my DAW. Also i want it to be as open as possible, so i will stick to midi for that project.

author

sorry never heard of it :) but i will check it out.

I use it with touchOSC and my ipad, also tested it wi the elektron machindrum.

If the device or app uses the standard midi protocol it should run with this Instructable

About This Instructable

23,417views

194favorites

License:

Bio: I'm a 36 year old DIY enthusiast from Vienna Austria with a strong background in mechatronics/automation. My DIY field is mainly video/audio ... More »
More by InevitableCraftsLab:ELECAM 360 - BLADE 200 QX - FRP QUAD CHASSISARDUINO_ POLAR V PLOTTER ARDUINO 433MHz _ SERVO.h vs VIRTUALWIRE.h
Add instructable to: