Skip to content

Commit 58f7e7d

Browse files
committed
added Basic_IO example
1 parent 167aa34 commit 58f7e7d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/Basic_IO/Basic_IO.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <USB-MIDI.h>
2+
3+
// Simple tutorial on how to receive and send MIDI messages.
4+
// Here, when receiving any message on channel 4, the Arduino
5+
// will blink a led and play back a note for 1 second.
6+
7+
USBMIDI_CREATE_DEFAULT_INSTANCE();
8+
9+
void setup()
10+
{
11+
pinMode(LED_BUILTIN, OUTPUT);
12+
MIDI.begin(4); // Launch MIDI and listen to channel 4
13+
}
14+
15+
void loop()
16+
{
17+
if (MIDI.read()) // If we have received a message
18+
{
19+
digitalWrite(LED_BUILTIN, HIGH);
20+
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
21+
delay(1000); // Wait for a second
22+
MIDI.sendNoteOff(42, 0, 1); // Stop the note
23+
digitalWrite(LED_BUILTIN, LOW);
24+
}
25+
}

0 commit comments

Comments
 (0)