Hi.
It is my first time on the Arduino forum.
I need some help please.
Just so you know, english is not my first language, I'll do my best.
Here's my situation :
I have an Arduino Uno v3.
I'm a musician and I work with a Korg Electribe drum machine which sends midi timing clock signal thru it's MIDI out.
I play with a drummer/percussionist and would like him to see midi timing clock signal outputted by the drum machine.
I thought of using a LED plugged in pin 13 of the Arduino.
I made the connection with a MIDI cable on the Arduino as explained in the MIDI tutorial.
I did some research over the web to find some ideas for the code.
Here's the code I'm using right now but it does not work :
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;
byte midi_continue = 0xfb;
int play_flag = 0;
byte data;
void setup() {
Serial.begin(31250);
}
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)) {
Sync();
}
}
}
void Sync() {
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13, LOW);
delay(10);
}
Would you have any idea what is wrong with my code?
Thank very much for your help.
Moderator edit: [code] ... [/code] tags added. (Nick Gammon)