-
Notifications
You must be signed in to change notification settings - Fork 2
/
dinsync.ino
44 lines (34 loc) · 922 Bytes
/
dinsync.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <MIDI.h>
#define PIN_TRIGGER 4
#define PIN_STARTSTOP 7
#define CLOCK_DIVIDER 12
MIDI_CREATE_DEFAULT_INSTANCE(); // <-- This was missing. "MIDI.read not defined in scope"
void HandleStart() {
digitalWrite(PIN_STARTSTOP, HIGH);
}
void HandleContinue() {
digitalWrite(PIN_STARTSTOP, HIGH);
}
void HandleStop() {
digitalWrite(PIN_STARTSTOP, LOW);
}
void HandleClock() {
digitalWrite(PIN_TRIGGER, HIGH);
delayMicroseconds(2000);
digitalWrite(PIN_TRIGGER, LOW);
}
// -----------------------------------------------------------------------------
void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(115200);
pinMode(PIN_TRIGGER, OUTPUT);
pinMode(PIN_STARTSTOP, OUTPUT);
digitalWrite(PIN_TRIGGER, LOW);
MIDI.setHandleStart(HandleStart);
MIDI.setHandleStop(HandleStop);
MIDI.setHandleContinue(HandleContinue);
MIDI.setHandleClock(HandleClock);
}
void loop() {
MIDI.read();
}