-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathNoteOnOffEverySec.ino
48 lines (39 loc) · 975 Bytes
/
NoteOnOffEverySec.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
45
46
47
48
#include <USB-MIDI.h>
USBMIDI_CREATE_DEFAULT_INSTANCE();
unsigned long t1 = millis();
void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
{
Serial.print("NoteOn ");
Serial.print(inNumber);
Serial.print("\tvelocity: ");
Serial.println(inVelocity);
}
void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{
Serial.print("NoteOff ");
Serial.print(inNumber);
Serial.print("\tvelocity: ");
Serial.println(inVelocity);
}
void setup()
{
Serial.begin(115200);
while (!Serial);
MIDI.begin();
MIDI.setHandleNoteOn(handleNoteOn);
MIDI.setHandleNoteOff(handleNoteOff);
Serial.println("Arduino ready.");
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void loop()
{
MIDI.read();
if ((millis() - t1) > 500)
{
t1 = millis();
MIDI.sendNoteOn(27, 55, 1);
MIDI.sendNoteOff(27, 55, 1);
}
}