Sou novo na programação com Arduíno, mas consegui criar um controlador MIDI, para usar com softwares simuladores de amplificadores de guitarra, como o Bias FX2.
Tenho 8 footswitches conectados a um Arduino Micro. Usei a biblioteca MIDI e também a Bounce2, e está funcionando muito bem. Mas, eu gostaria de adicionar a funcionalidade de apertar 2 footswitches “ao mesmo tempo”, e assim mandar mensagens MIDI diferentes. Não faço ideia se é possível fazer isso no Arduíno. Segue meu sketch abaixo:
// Including the Libraries
#include <USB-MIDI.h>
#include <Bounce2.h>
USBMIDI_CREATE_DEFAULT_INSTANCE();
// Define number of Foot Switches (buttons), and the pin array
#define NUM_BUTTONS 8
const uint8_t BUTTON_PINS[NUM_BUTTONS] = {3, 4, 5, 6, 7, 8, 9, 10};
Bounce * buttons = new Bounce[NUM_BUTTONS];
void setup()
{
for (int i = 0; i < NUM_BUTTONS; i++)
{
buttons[i].attach( BUTTON_PINS[i] , INPUT_PULLUP );
buttons[i].interval(25);
}
MIDI.begin(1);
}
void loop()
{
for (int i = 0; i < NUM_BUTTONS; i++)
{
buttons[i].update();
if ( buttons[i].fell() )
{
MIDI.sendControlChange( i + 11, 127, 1);
}
}
}