Hi I'm trying to get in to Teensy 4.0 with a simple project.
By midi notes I would like to make a digitalWrite to specifics pins if it's a MIDI send G, E, and so one. If I'm using the code i can get it to work with key down. But how do i select a specific note?
I think that i could do something like
void setup() {
if(note=60){
pinMode(ledPin, OUTPUT);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn) ;
digitalWrite(ledPin, HIGH);
delay(400); // Blink LED once at startup
digitalWrite(ledPin, LOW);
}
}
Code from tutorial.
// 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();
}
By midi notes I would like to make a digitalWrite to specifics pins if it's a MIDI send G, E, and so one. If I'm using the code i can get it to work with key down. But how do i select a specific note?
I think that i could do something like
void setup() {
if(note=60){
pinMode(ledPin, OUTPUT);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn) ;
digitalWrite(ledPin, HIGH);
delay(400); // Blink LED once at startup
digitalWrite(ledPin, LOW);
}
}
Code from tutorial.
// 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();
}