26 lines
755 B
C++
26 lines
755 B
C++
#include <MIDI.h>
|
|
|
|
// Override the default MIDI baudrate to
|
|
// a decoding program such as Hairless MIDI (set baudrate to 115200)
|
|
|
|
struct CustomBaudRate : public MIDI_NAMESPACE::DefaultSettings {
|
|
static const long BaudRate = 115200;
|
|
};
|
|
|
|
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);
|
|
|
|
void setup() {
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
MIDI.begin(MIDI_CHANNEL_OMNI);
|
|
}
|
|
|
|
void loop() {
|
|
if (MIDI.read()) // If we have received a message
|
|
{
|
|
digitalWrite(LED_BUILTIN, HIGH);
|
|
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
|
|
delay(1000); // Wait for a second
|
|
MIDI.sendNoteOff(42, 0, 1); // Stop the note
|
|
digitalWrite(LED_BUILTIN, LOW);
|
|
}
|
|
} |