1) Reading MIDI Clock

To read MIDI-clock on an Arduino one needs a galvanic separation by an opto coupler. I used a GNY17-2. Use of other ICs (6N137, 6N138 or 4N28) are also possible and the schematics can easily be found on the web.

Parts list
-Resistor 220 Ohm
-Resistor 100 kOhm
-opto coupler IC GNY17-2
-5-pole DIN female connector (180°)
-MIDI cable
-MIDI sync master (here: Roland TR-505)
-Arduino (here: Arduino Mega. For this demo also Arduinos with less input and output channels will work)


The resistor connected to the MIDI jack is 220 Ohm, the other resistor is 100 kOhm.
As MIDI clock genarator a Roland TR-505 was used.
As LED I used the SMD-LED on the arduino board. You may also connect one to PIN13 (don´t forget the resistor to ground).

For a first attempt to sync the sequencer to MIDI-clock I used the software template of littlescale. Changes were so far only made in the Sync() function.


The following code lets a LED light for the first half of a bar, while it is off for the second half of the bar. Please note that the delay() function was avoided and only clock_step was used for syncronization.

// Declaration of Varialbes
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;
byte midi_continue = 0xfb;
int play_flag = 0;
byte data;
int clock_step;

// Initialization
void setup() {

// Main Programm
void loop() {
if(Serial.available() > 0) {
data = Serial.read();
if(data == midi_start) {
play_flag = 1;
else if(data == midi_continue) {
play_flag = 1;
else if(data == midi_stop) {
play_flag = 0;
else if((data == midi_clock) && (play_flag == 1)) {

// Function

void Sync() { // 1st half of a bar: LED=on, seconds half of a bar: LED=off
clock_step = clock_step+1;
if (clock_step==1){
digitalWrite(13, HIGH); // set the LED on
else if (clock_step==96/2){
digitalWrite(13, LOW); // set the LED off
else if (clock_step==96){


  1. that's very interesting !

    there is not that much many projects like that on the web.

    you're in my bookmarks !

  2. Thanks, the code is not perfect at the moment, but I will improve it when I have time...

  3. How about a GIANT sequencer/drum computer?

    A wall of lets say 20x20 cm plexiglas cubes with leds behind them and touch sensors.

    8x5 for kick, snare, hats, toms, whatever.

    I know what i'm gonna make this summer ;)
    Thanks for the code mate.