kriista
Member
So I've got a Teensy 3.0 which I bought specifically for this USB-MIDI to Relay box I'm building.
Here's what the hardware itself looks like (all repurposed/vintage parts!):
The guts are set up such that when each relay receives 5v it fires.
So what I'm trying to do with the Teensy code is read MIDI note messages and set corresponding digital pins to HIGH.
I'm thinking of using MIDI notes 60-75 and digital pins 1-16, so pressing MIDI note 60 will set digital pin 1 HIGH, and releasing it would set it back to LOW.
I had made a thread about an earlier version of this project which I found super useful in wrapping my head around how easy USB-MIDI is to do with Teensy (amazing!) here:
http://forum.pjrc.com/threads/24085-USB-MIDI-device-(all-inputs-outputs)?p=34576
The main takeaway was looking at this page:
http://www.pjrc.com/teensy/td_midi.html
On there I see code that does what I want pretty much, EXCEPT it's only working with one digital pin. Because of how the functions are set up, I actually don't know how to modify this code so it does what I said above (map MIDI notes to digital pins).
This is the LED controlled by MIDI code:
Any help here would be appreciated!
Here's what the hardware itself looks like (all repurposed/vintage parts!):
The guts are set up such that when each relay receives 5v it fires.
So what I'm trying to do with the Teensy code is read MIDI note messages and set corresponding digital pins to HIGH.
I'm thinking of using MIDI notes 60-75 and digital pins 1-16, so pressing MIDI note 60 will set digital pin 1 HIGH, and releasing it would set it back to LOW.
I had made a thread about an earlier version of this project which I found super useful in wrapping my head around how easy USB-MIDI is to do with Teensy (amazing!) here:
http://forum.pjrc.com/threads/24085-USB-MIDI-device-(all-inputs-outputs)?p=34576
The main takeaway was looking at this page:
http://www.pjrc.com/teensy/td_midi.html
On there I see code that does what I want pretty much, EXCEPT it's only working with one digital pin. Because of how the functions are set up, I actually don't know how to modify this code so it does what I said above (map MIDI notes to digital pins).
This is the LED controlled by MIDI code:
Code:
// 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);
}
void OnNoteOff(byte channel, byte note, byte velocity)
{
digitalWrite(ledPin, LOW);
}
void setup()
{
pinMode(ledPin, OUTPUT);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn) ;
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
void loop()
{
usbMIDI.read();
}
Any help here would be appreciated!