Hi
I am trying to get 2 leds to turn on and off from a Midi Control Change, 82 for led 1 and 83 for led2. it works at the moment for just 82 led1 and not for the second led. can someone tell me where i have gone wrong in the code.
The plan would be to control 8 leds.
Thank you
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
// Let's define the MIDI channel
#define MIDI_CHANNEL 1
// The LED we're going to light
#define LED 13
#define LED2 9
// The CC we'll handle, can be changed
//The CC values we'll handle, can be changed
#define CC_TOGGLE_ON 127
#define CC_TOGGLE_OFF 0
MIDI_CREATE_DEFAULT_INSTANCE();
int pc;
int cc;
int ccValue;
void setup() {
// Starting to listen on the specified MIDI channel
MIDI.begin(MIDI_CHANNEL);
pinMode(LED, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop() {
int CCnumber[8] = {82, 83, 22, 23, 24, 25, 26, 27};
// If we have a message, we treat it
if (MIDI.read()) {
// Get the type of the message we caught
switch(MIDI.getType()) {
// If it is a Control Change
case midi::ControlChange:
cc = MIDI.getData1();
if (cc == CCnumber[0]) {
ccValue = MIDI.getData2();
if (ccValue == CC_TOGGLE_OFF) {
digitalWrite(LED, HIGH);
} else if (ccValue == CC_TOGGLE_ON) {
digitalWrite(LED, LOW);
}
}
break;
cc = MIDI.getData1();
if (cc == CCnumber[1]) {
ccValue = MIDI.getData2();
if (ccValue == CC_TOGGLE_OFF) {
digitalWrite(LED2, HIGH);
} else if (ccValue == CC_TOGGLE_ON)
}
}
break;
}
}
}