-
-
Save 01GOD/72e928b47c6b7c15107e8f061ad1aaf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Arduino-BLE-MIDI Library | |
//https://github.com/lathoub/Arduino-BLE-MIDI | |
#include <BLEMIDI_Transport.h> | |
#include <hardware/BLEMIDI_ESP32.h> | |
BLEMIDI_CREATE_DEFAULT_INSTANCE() | |
void setup() { | |
pinMode(12, OUTPUT); | |
pinMode(14, OUTPUT); | |
MIDI.begin(); | |
} | |
void loop() { | |
uint8_t data1; | |
uint8_t data2; | |
if (MIDI.read()) { //when get MIDI signal | |
switch (MIDI.getType()) { | |
case midi::NoteOn: | |
data1 = MIDI.getData1(); //get note number | |
data2 = MIDI.getData2(); //get velocity (this value is not used in this code.) | |
if (data1 > 60) { | |
digitalWrite(12, HIGH); | |
} else { | |
digitalWrite(14, HIGH); | |
} | |
break; | |
case midi::NoteOff: | |
data1 = MIDI.getData1(); //get note number | |
data2 = MIDI.getData2(); //get velocity (this value is not used in this code.) | |
if (data1 > 60) { | |
digitalWrite(12, LOW); | |
} else { | |
digitalWrite(14, LOW); | |
} | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment