Code could be something like this as a starting point. Read a switch, turn LED on/off with alternate presses.
(not compiled, should be pretty close)
/*
D2-D9 are switch inputs
D10-D17 are LED outputs, High = LED on, don’t forget current limit resistors
D0, D1 are serial to start, MIDI IO later
*/
LEDstate[ ] = {0,0,0,0,0,0,0,0,0,0}; // hold state of the LEDs, 2 extra since not using 0, 1
unsigned long readTime; // keep track of elapsed time, blink without delay style
void setup(){
// short loop to set up input pins with pullup resistors
for (byte x = 2; x<10; x=x+1){
pinMode (x, INPUT);
digitalWrite (x, HIGH);
}
// short loop to set up output pins
for (byte x = 10; x<18; x=x+1){
pinMode (x, OUTPUT);
digitalWrite (x, LOW);
}
Serial.begin(9600); // use serial monitor to send regular message to start, replace with MIDI at 31500 when ready
} // end setup
void loop(){
if (millis()>=readTime){
readTime = readTime +5; // read the switches every 5mS
// read the switches, flip status bits as needed
for (byte x = 2; x<10; x=x+1){
if (digitalRead (x) == LOW){
LEDstate[x] = 1 – LEDstate[x]; // results in 1,0,1,0 on switch closures from pin to ground
digitalWrite (x+8, LEDstate[x] ); // press 2, turn 10 on/off. press 3, turn 11 on/off. Etc.
Serial.print (“switch & state : “);
Serial.print (x);
Serial.println (LEDstate[x]);
} //end read/write
} // end 2-9 loop
} // end time check
} // end void loop