2010-10-31

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
-Diode
-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)

Schematics

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.




Software

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() {
Serial.begin(31250);
clock_step=0;
}

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



// 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){
clock_step=0;
}
}


Syncuino - An Arduino-based step Sequencer


In this blog I will report about developement of an
Arduino Mega based step sequencer. It will have the following features:

1) Syncable to external MIDI-Clock (responding to Start-, Stop-, Continue- and Clock-singals) ok
2) Output of MIDI Notes
ok
3) For each step one note can be chosen by a potentiometer
(1 hardware-potentiometer for each step) ok
4) A shuffle rhythm function ok
5) LEDs indicate the actual step (1 LED for each step) ok

Videos will be hosted here.