Introduction: Old-School Arduino MIDI Sequencer

About: If you enjoyed some of my projects, please take a moment an listen to some of the music of Bomber Goggles and Gekko Projekt. I play keyboards and write a lot of the music.
Using a standard Arduino single-board computer and a "shield" board, this project creates a MIDI sequencer that can record and play back sequences of MIDI notes.  It is similar to old-school sequencers in that the sequence is monophonic (one note at a time), and with each step in the sequence plays for one beat of the tempo.  Note that the sequencer doesn't make any sound itself; it generates a MIDI stream that can play a MIDI keyboard, a MIDI sound module or even a virtual instrument hosted on a computer.

You can see a short demo below.  I talk for a bit at the beginning, but hang in there, I do two demos of it.
The project consists of two commercially produced circuit boards.  The single-board computer (blue in the picture) can be purchased online for about $30, and comes fully assembled.  The "shield" board (red in the picture) comes partially assembled, but you will have to solder the pushbuttons, connectors and potentiometers (knobs).  It runs about $20 online.

What You Need For This Project
1 Arduino Uno or similar Arduino single-board computer
1 SparkFun MIDI Shield
1 Strip of 40 straight break-away headers with 0.1" spacing
A soldering iron with solder
Wire clippers
A computer (PC/Mac/Linux) with free Arduino software installed
A USB cable appropriate to connect the computer to your Arduino

Other Stuff Needed to Use the Sequencer
1 AC adapter for Arduino
2 5-pin DIN MIDI cables
1 MIDI keyboard or sound module
Speakers or headphones to listen

Arduino and AC adapter:

MIDI Shield and headers:

f you are in a hurry to get started, many Radio Shacks also carry Arduinos.

Step 1: Solder Components Onto the MIDI Shield

The MIDI Shield comes only partly assembled.  You will need to solder the 2 5-pin DIN MIDI connectors, 3 pushbuttons and 2 potentiometers (knobs) onto the circuit board, but the tricky parts have already been soldered for you. 

Follow the instructions that come with the MIDI Shield.  Make sure the components are all on the right side of the board (the same side as the IC chip), and are pushed in to be flush with the board surface.  After you finish soldering, I recommend you reflow each of your solder junctions by holding the soldering iron against it for 2-3 seconds.

Note: The header pins along the edges of the board are soldered in the next step.

Step 2: Add the Headers to the MIDI Shield

As shown in the picture, break off segments of the strip of headers to go into the four strips of holes along the edges of the MIDI Shield.  The headers go on the back side of the MIDI Shield. 

It will be easiest to solder them in with the long section of the headers inserted into the Arduino, and the MIDI Shield placed over it with the short end of the headers poking through the holes.  If the MIDI Shield will not go all the way down onto the header pins, you may have to trim some of your previous solder junctions with wire clippers so they do not touch Arduino components.

Note: Some recent Arduinos will have sockets for two extra pins at the USB end along either edge.  The MIDI Shield and MIDI sequencer will work fine without having the extra pins.

After you have soldered all of the pins from the top side of the MIDI Shield, I recommend you reflow these solder junctions as you did in Step 2 for the previous ones.

Step 3: Install the Timer Library

Make sure you have a recent version of Arduino software installed on your computer.  I did the development for this project using version 1.0.5.  Download the timer library and follow the directions at the site to add it to the libraries directory of your Arduino software.  You can find the timer library at JChristensen's GitHub Page.

Step 4: Compile the Firmware

Unzip the zip file attached.  It contains an Arduino "sketch" (what they call an Arduino program).  Open the file midiSeqRec.ino in the Arduino development software. 

From the menu, select Sketch->Import Library->Add Library, and add the timer library you installed in Step 3 to the project, and save the project.  From the menu, select Sketch->Verify/Compile, and ensure that it compiles without error.

Step 5: Program the Arduino

Connect the Arduino circuit board to your computer using a USB cable.  You do not need to attach power to the Arduino because the USB connection will power it.  In the Arduino software, in the Tools menu, select the type of Arduino you are using, and the port it is connected to. 

Then, from the menu, select File->Upload.  Ensure that the software compiles correctly and completes uploading to the Arduino board. 

Note: if you are doing this with the MIDI Shield attached to the Arduino, the switch on the MIDI Shield must be set to Prog for programming to work.

Step 6: Test the Sequencer

Disconnect the Arduino from the USB cable, attach the MIDI Shield to the Arduino (if it is not attached already), and then connect the Arduino to an AC adapter to power it.  (You can also use a battery pack.)  Connect the MIDI Out of the MIDI Shield to the MIDI In of a MIDI keyboard or sound module. 

Note: The board will transmit on the default MIDI channel (channel 1), so if your keyboard has had its MIDI channel changed, set it back to channel 1 or put it in Omni mode (receives all channels). 

Press the Play button (the picture shows the button assignments).  The sequencer will play the sequence used by Pink Floyd in the song On The Run, and turn on a green LED while it is playing.  You can try adjusting the Velocity and  Tempo knobs to see how these affect the sound.  You can stop the sequence by pressing the Stop button, at which point the green LED will turn off.

Demo Trivia: In the demo video I used a Korg M-50 keyboard, and a stock factory sound called Trance Form Lead (D 090), a monophonic lead synth sound.  Many synths should have a stock sound that is similar.  In the video, I adjusted the filter cutoff frequency and filter resonance (sometimes called Q) on the keyboard to create a similar effect to the original Pink Floyd track.

Step 7: Record a Sequence

Connect the MIDI In of the MIDI Shield to the MIDI Out of a MIDI keyboard or other MIDI instrument.  Set the small slide switch on the MIDI Shield to the Run position (required for recording). 

Press the Record button.  The red LED will light up.  Play some notes on the keyboard, and then press the Record button again.  The red LED will go out, the green LED will light, and your new sequence will begin playing.  The MIDI sequencer can store sequences of up to 127 notes.

If you make a mistake in entering the notes, press the Stop button, and the sequencer will exit the Record mode.  You can then press the Record button and start recording from the beginning.

Step 8: Stuff to Try

  • If you are interested in extending the firmware (the Arduino sketch), I've set up a GitHub page for it.  GitHub provides a pretty good environment for working cooperatively to extend open-source software like this.
  • One modification you can do pretty easily to the firmware is to change the default sequence that it plays before you've recorded a new one.  In the firmware source code find this line:

    int sequence[128] = { 40, 43, 45, 43, 50, 48, 50, 52, 0 };

    The numbers in brackets on the right side of the equal sign are the MIDI note numbers of the notes in the sequence.  Just replace them with the numbers of the notes you want in your sequence, recompile and upload to the Arduino.  60 is the note number of middle C, 61 is the note number of C# above it, etc.  Make sure to put a zero at the end (that tells the sequencer where the end of the sequence is), and separate the numbers with commas.
  • The firmware is released under the MIT license.  You can do anything you want with it, including using it for commercial purposes.  The license says you are allowed "to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software."  The only requirement is that you include the copyright and license information at the top of the source code in any derivative works.  That said, if you make improvements, I'd appreciate you contributing them to the GitHub repository.
Microcontroller Contest

Participated in the
Microcontroller Contest