Hi,
I am very new to Arduino and programming.
I am trying to build a simple MIDI Foot controller to send Control Change Messages to my guitar
effect pedals.
I have be working with the following sketch which allows me to:
Send a CC# or CC Toggle per button, But I can’t send a value with the CC#.
I need to send multiple CC messages (with a value) on up to Three (3) MIDI Channels per button.
E.G.
BUTTON 1 -( CC# 2, Value 0, Chanel 5) & (CC# 31, Value 127, Chanel 3 ) & (CC# 4, Value 3, Chanel 5)
Also I have noticed when I use the CC command, the button is only momentary, I need it to Latch.
Like I said before, I’m a complete beginner, I have spent weeks reading articles and watching tutorials.
I have well and truly hit a brick wall, So any help will be greatly appreciated!
HERE IS THE CODE I'VE BEEN WORKING WITH.
#include <MIDI.h>
#include "Controller.h"
MIDI_CREATE_DEFAULT_INSTANCE();
//---How many buttons are connected directly to pins?---------
byte NUMBER_BUTTONS = 2;
//***DEFINE DIRECTLY CONNECTED BUTTONS*******************************
//Button (Pin Number, Command, Note Number, Channel, Debounce Time)
//** Command parameter 0=NOTE 1=CC 2=Toggle CC **
Button BU1(2, 1, 2, 3, 5 );
Button BU2(3, 1, 31, 3, 3 );
//Add buttons used to array below like this-> Button *BUTTONS[] {&BU1, &BU2, &BU3, &BU4, &BU5, &BU6, &BU7, &BU8};
Button *BUTTONS[] {&BU1, &BU2};
void setup() {
MIDI.begin(MIDI_CHANNEL_OFF);
}
void loop() {
if (NUMBER_BUTTONS != 0) updateButtons();
}
//*****************************************************************
void updateButtons() {
// Cycle through Button array
for (int i = 0; i < NUMBER_BUTTONS; i = i + 1) {
byte message = BUTTONS[i]->getValue();
// Button is pressed
if (message == 0) {
switch (BUTTONS[i]->Bcommand) {
case 0: //Note
MIDI.sendNoteOn(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
break;
case 1: //CC
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
break;
case 2: //Toggle
if (BUTTONS[i]->Btoggle == 0) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 1;
}
else if (BUTTONS[i]->Btoggle == 1) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 0;
}
break;
}
}
// Button is not pressed
if (message == 1) {
switch (BUTTONS[i]->Bcommand) {
case 0:
MIDI.sendNoteOff(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
break;
case 1:
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
break;
}
}
}
}