Last active
September 4, 2023 14:59
-
-
Save RyoKosaka/9851abbf0393aa6790a14c4806656f04 to your computer and use it in GitHub Desktop.
This file contains hidden or 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