i need some help understanding the way the below example by Alessandro Fasan works, so that i can then expand it to do something a bit different: rather than just flashing an LED on pin 13, respond to 3 different incoming midi note values (any, totally arbitrary) so that each trigger an LED on different pins.
i'm using Teensy 3.5, btw.
any pointers will be much appreciated. i'm sure something along these lines must exist in the forums already, cause it's quite basic i assume, but i was not able to find it.
// USB MIDI receive example, Note on/off -> LED on/off
// contributed by Alessandro Fasan
int ledPin = 13;
void OnNoteOn(byte channel, byte note, byte velocity) {
digitalWrite(ledPin, HIGH); // Any Note-On turns on LED
}
void OnNoteOff(byte channel, byte note, byte velocity) {
digitalWrite(ledPin, LOW); // Any Note-Off turns off LED
}
void setup() {
pinMode(ledPin, OUTPUT);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn) ;
digitalWrite(ledPin, HIGH);
delay(400); // Blink LED once at startup
digitalWrite(ledPin, LOW);
}
void loop() {
usbMIDI.read();
}
i'm using Teensy 3.5, btw.
any pointers will be much appreciated. i'm sure something along these lines must exist in the forums already, cause it's quite basic i assume, but i was not able to find it.
// USB MIDI receive example, Note on/off -> LED on/off
// contributed by Alessandro Fasan
int ledPin = 13;
void OnNoteOn(byte channel, byte note, byte velocity) {
digitalWrite(ledPin, HIGH); // Any Note-On turns on LED
}
void OnNoteOff(byte channel, byte note, byte velocity) {
digitalWrite(ledPin, LOW); // Any Note-Off turns off LED
}
void setup() {
pinMode(ledPin, OUTPUT);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn) ;
digitalWrite(ledPin, HIGH);
delay(400); // Blink LED once at startup
digitalWrite(ledPin, LOW);
}
void loop() {
usbMIDI.read();
}