From 3ae9fe9ae71ea2111a255bcf50c3f689589dac72 Mon Sep 17 00:00:00 2001 From: lathoub Date: Sat, 18 Apr 2020 16:05:24 +0200 Subject: [PATCH] added Basic_IO example --- examples/Basic_IO/Basic_IO.ino | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/Basic_IO/Basic_IO.ino diff --git a/examples/Basic_IO/Basic_IO.ino b/examples/Basic_IO/Basic_IO.ino new file mode 100644 index 0000000..dd49631 --- /dev/null +++ b/examples/Basic_IO/Basic_IO.ino @@ -0,0 +1,26 @@ +#include +#include + +// Simple tutorial on how to receive and send MIDI messages. +// Here, when receiving any message on channel 4, the Arduino +// will blink a led and play back a note for 1 second. + +BLEMIDI_CREATE_DEFAULT_ESP32_INSTANCE() + +void setup() +{ +// pinMode(LED_BUILTIN, OUTPUT); + MIDI.begin(4); // Launch MIDI and listen to channel 4 +} + +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); + } +}