void loop(){ //This for loop is used to scroll through and store the 16 inputs on the FIRST multiplexer for (int i=0; i<16; i++) { //The following 4 commands set the correct logic for the control pins to select the desired input //See the Arduino Bitwise AND Reference: http://www.arduino.cc/en/Reference/BitwiseAnd //See the Aruino Bitshift Reference: http://www.arduino.cc/en/Reference/Bitshift digitalWrite(CONTROL0, (i&15)>>3); digitalWrite(CONTROL1, (i&7)>>2); digitalWrite(CONTROL2, (i&3)>>1); digitalWrite(CONTROL3, (i&1));

Excellent, thank you so much! That works perfectly. I think I understand how the mux shield works a bit better now, too.I have another question though:

I will eventually have 16 inputs (and outputs). Would I be able to store the buttonState values in an array, and then iterate through the array and call the digitalReadMUX function on each value? Something like this: