Midi Foot Controller - Need help - Can not figure out Midi receive
I'm working on a Midi Foot Controller and use a Teensy 2.0 and arduino ide. I made a workable code (sorry for that I am a newbie and this is only from parts of other projects) for 3 buttons with toggle function and sending Midi from Button 1 and Button 2. This is working quite well. Tried to add a midi receive, but it did not work. I don't understand how to do that.
So if a software (via preset) sends an on message from control 85, the LED1 of the controller should go on (and vice versa). Here is the working code with Midi send and Buttons/LEDs.
Code:
//Buttons, LEDs
#include <ButtonSwitch.h>int buttonPin1 = 0; // define Pin XXX as the input of the button signal
int LED1 = 11; // define Pin XXX as the input of the LED signal
int buttonPin2 = 1;
int LED2 = 12;
int buttonPin3 = 2;
int LED3 = 13;// declare button as a data type of Button_Switch connected to the buttonPin (in this case pin xxx of the Arduino),
buttonSwitch button1(buttonPin1);
buttonSwitch button2(buttonPin2);
buttonSwitch button3(buttonPin3);// the setup function runs once when you press reset or power the board
//Midi Send Bounce
#include <Bounce.h> // Bounce library makes button change detection easy
const int channel = 1;Bounce switch1 = Bounce(buttonPin1, 5); // 5 = 5 ms debounce time
Bounce switch2 = Bounce(buttonPin2, 5); // which is appropriate for goodvoid setup() {
pinMode(LED1, OUTPUT); // initialize digital pin LED_BUILTIN as an output
pinMode(buttonPin1, INPUT_PULLUP); // initialize digital pin for the push button as an inputpinMode(LED2, OUTPUT);
pinMode(buttonPin2, INPUT_PULLUP);pinMode(LED3, OUTPUT);
pinMode(buttonPin3, INPUT_PULLUP);
}// the loop function runs over and over again forever
void loop() {
digitalWrite(LED1, button1.SwitchI()); // turns the builtin LED on or off if the button was pushed
digitalWrite(LED2, button2.SwitchI());
digitalWrite(LED3, button3.SwitchI());delay(10); // little delay needed to debounce the push button
//Loop Midi Send
switch1.update();
switch2.update();// Note On messages when each button is pressed
if (switch1.fallingEdge()) {
usbMIDI.sendControlChange(85, 127, 1);
}
if (switch2.fallingEdge()) {
usbMIDI.sendControlChange(86, 127, 1);
}// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
}
}Maybe someone could help me to write an add for this code to receive midi message as discribed. Thanks a lot!!!