mikemontauk
Active member
Hello, I am using the Teensy (LC) to illuminate LEDs based on the MIDI note-on received. I manually assigned 5 notes (e.g. 60, 61, 62, 63, 64) to 5 LEDs. It's working nicely; when I press one of the 5 assigned notes on my keyboard the correct/corresponding LEDs illuminate.
Next, I want to create an ISR so that when a push-button is pressed, the program 'learns' the next 5 MIDI notes received (stores and maps them to outputs).
High-level description of desired process and steps:
a) push-button pressed;
b) wait for 5 MIDI notes received, e.g.: 56, 57, 70, 79, 90; then
c) map 56, 57, 70, 79, 90 to specified 5 outputs
d) result - MIDI note-on messages 56, 57, 70, 79, 90 will trigger the LEDs.
I have tried implementing a 'for' loop in an ISR to record the next 5 midi note-on messages in an array but I can't figure out how to 'wait' for 5 MIDI notes. (My loop terminates before 5 notes can be pressed and the array ends up being 5 of the same note.) I think this is because "you must call usbMIDI.read() regularly from loop() for usbMIDI to actually read incoming data and run the handler functions as messages arrive."
I suspect I need to run usbMIDI.read() inside a loop inside my ISR but I cannot find direction on how to do so. Any help would be appreciated. Best regards.
Next, I want to create an ISR so that when a push-button is pressed, the program 'learns' the next 5 MIDI notes received (stores and maps them to outputs).
High-level description of desired process and steps:
a) push-button pressed;
b) wait for 5 MIDI notes received, e.g.: 56, 57, 70, 79, 90; then
c) map 56, 57, 70, 79, 90 to specified 5 outputs
d) result - MIDI note-on messages 56, 57, 70, 79, 90 will trigger the LEDs.
I have tried implementing a 'for' loop in an ISR to record the next 5 midi note-on messages in an array but I can't figure out how to 'wait' for 5 MIDI notes. (My loop terminates before 5 notes can be pressed and the array ends up being 5 of the same note.) I think this is because "you must call usbMIDI.read() regularly from loop() for usbMIDI to actually read incoming data and run the handler functions as messages arrive."
I suspect I need to run usbMIDI.read() inside a loop inside my ISR but I cannot find direction on how to do so. Any help would be appreciated. Best regards.