MIDI TO ARDUINO

27,121

203

17

About: 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/motion control. If you want to see what i do between posting it ...

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.



Share

    Recommendations

    • PCB Contest

      PCB Contest
    • Toys Contest

      Toys Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    17 Discussions

    0
    None
    Hans15G

    Question 7 weeks ago

    Hay can you tell me what a 4n35 is and what it can do?

    1 answer
    0
    None
    InevitableCraftsLabHans15G

    Reply 7 weeks ago

    Hi, yes its an optocoupler.

    https://www.datasheetspdf.com/datasheet/search.php?sWord=4n35

    A few words on optocouplers/isolators :

    https://en.m.wikipedia.org/wiki/Opto-isolator

    Basically its a light dependend switch together with a light diode in a housing.

    By turning on the LED on the input side you switch the output side.

    You use it to secure inputs of microcontrollers.
    Lets assume you put 12V on the input by accident, if you wouldnt have an optocoupler installed you would burn the microcontroller. with an optocoupler you burn the coupler instead of the chip :)

    Take a read of the wiki article, and also: honestly google stuff up if you wanna know about them, most often its easier than posting a question and waiting for someone to explain it ;)

    Also you learn more from reading articles and datasheets than from random people on the internet ;)

    Thats all part of beeing a developer.

    0
    None
    Stroopalini

    1 year ago

    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?

    1 reply
    0
    None
    InevitableCraftsLabStroopalini

    Reply 6 months ago

    Hi, sorry i just read this message. I am about to build a few of those over the next few days. I will come back and change the graphics if i find some errors.

    0
    None
    ayhankaplan

    1 year ago

    Thanks for this!

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

    1 reply
    0
    None
    franciscog34

    1 year ago

    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.

    2 replies

    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

    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.

    0
    None
    RobB163EnesY4

    Reply 1 year ago

    add this under include midi.h

    MIDI_CREATE_DEFAULT_INSTANCE();

    0
    None
    snoop911

    3 years ago on Introduction

    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.

    2 replies

    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.

    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