Hi mekon!
Thanks for you help!
The point is that I have alot of arrays since i have 24 4021 shift reg.
I would like to "compress" a bit the code, if possible.
I already have 4 array for each 4021, that makes 24 x 4.
The beginning of the program looks like this:
// Define variables to hold the data for each shift register.
byte muxButtons1 = 0;
byte muxButtons2 = 0;
byte muxButtons3 = 0;
byte muxButtons4 = 0;
byte muxButtons5 = 0;
byte muxButtons6 = 0;
byte muxButtons7 = 0;
byte muxButtons8 = 0;
byte muxButtons9 = 0;
byte muxButtons10 = 0;
byte muxButtons11 = 0;
byte muxButtons12 = 0;
byte muxButtons13 = 0;
byte muxButtons14 = 0;
byte muxButtons15 = 0;
byte muxButtons16 = 0;
byte muxButtons17 = 0;
byte muxButtons18 = 0;
byte muxButtons19 = 0;
byte muxButtons20 = 0;
byte muxButtons21 = 0;
byte muxButtons22 = 0;
byte muxButtons23 = 0;
byte muxButtons24 = 0;
// General midi notes
char buttonsMuxNotes1[] = {1, 1, 1, 3, 4, 5, 6, 7};
char buttonsMuxNotes2[] = {8, 9, 10, 11, 12, 13, 14, 15};
char buttonsMuxNotes3[] = {16, 17, 18, 19, 20, 21, 22, 23};
char buttonsMuxNotes4[] = {24, 25, 26, 27, 28, 29, 30, 31};
char buttonsMuxNotes5[] = {32, 33, 34, 35, 36, 37, 38, 39};
char buttonsMuxNotes6[] = {40, 41, 42, 43, 44, 45, 46, 47};
char buttonsMuxNotes7[] = {48, 49, 50, 51, 52, 53, 54, 55};
char buttonsMuxNotes8[] = {56, 57, 58, 59, 60, 61, 62, 63};
char buttonsMuxNotes9[] = {64, 65, 66, 67, 68, 69, 70, 71};
char buttonsMuxNotes10[] = {72, 73, 74, 75, 76, 77, 78, 79};
char buttonsMuxNotes11[] = {80, 81, 82, 83, 84, 85, 86, 87};
char buttonsMuxNotes12[] = {88, 89, 90, 91, 92, 93, 94, 95};
char buttonsMuxNotes13[] = {0, 1, 2, 3, 4, 5, 6, 7};
char buttonsMuxNotes14[] = {8, 9, 10, 11, 12, 13, 14, 15};
char buttonsMuxNotes15[] = {16, 17, 18, 19, 20, 21, 22, 23};
char buttonsMuxNotes16[] = {24, 25, 26, 27, 28, 29, 30, 31};
char buttonsMuxNotes17[] = {32, 33, 34, 35, 36, 37, 38, 39};
char buttonsMuxNotes18[] = {40, 41, 42, 43, 44, 45, 46, 47};
char buttonsMuxNotes19[] = {48, 49, 50, 51, 52, 53, 54, 55};
char buttonsMuxNotes20[] = {56, 57, 58, 59, 60, 61, 62, 63};
char buttonsMuxNotes21[] = {64, 65, 66, 67, 68, 69, 70, 71};
char buttonsMuxNotes22[] = {72, 73, 74, 75, 76, 77, 78, 79};
char buttonsMuxNotes23[] = {80, 81, 82, 83, 84, 85, 86, 87};
char buttonsMuxNotes24[] = {88, 89, 90, 91, 92, 93, 94, 95};
// Status of each button of the mux
boolean buttonsMuxStatus1[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus2[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus3[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus4[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus5[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus6[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus7[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus8[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus9[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus10[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus11[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus12[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus13[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus14[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus15[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus16[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus17[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus18[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus19[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus20[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus21[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus22[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus23[] = {0,0,0,0,0,0,0,0};
boolean buttonsMuxStatus24[] = {0,0,0,0,0,0,0,0};
// Midi channel where to send notes for each mux
#define buttonsMuxMidiChannel1 1
#define buttonsMuxMidiChannel2 1
#define buttonsMuxMidiChannel3 2
#define buttonsMuxMidiChannel4 2
#define buttonsMuxMidiChannel5 8
#define buttonsMuxMidiChannel6 8
#define buttonsMuxMidiChannel7 4
#define buttonsMuxMidiChannel8 1
#define buttonsMuxMidiChannel9 1
#define buttonsMuxMidiChannel10 2
#define buttonsMuxMidiChannel11 2
#define buttonsMuxMidiChannel12 8
#define buttonsMuxMidiChannel13 8
#define buttonsMuxMidiChannel14 4
#define buttonsMuxMidiChannel15 1
#define buttonsMuxMidiChannel16 1
#define buttonsMuxMidiChannel17 2
#define buttonsMuxMidiChannel18 2
#define buttonsMuxMidiChannel19 8
#define buttonsMuxMidiChannel20 8
#define buttonsMuxMidiChannel21 4
#define buttonsMuxMidiChannel22 1
#define buttonsMuxMidiChannel23 1
#define buttonsMuxMidiChannel24 2