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.
-Resistor 220 Ohm
-Resistor 100 kOhm
-opto coupler IC GNY17-2
-5-pole DIN female connector (180°)
-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.