The initial example I wrote used seven pins but you only need 5 (my bad), just changed the 7 to a 5 in the initial pin table and any for/next loops that use it. Hopefully this will work and compile fine.
// List of input pins to read
const int Input_Pins [5] = {
3,4,5,6,7};
void setup(){
// set list of pins to input
for (int a=0;a<5;a++){
pinMode(Input_Pins[a],INPUT);
}
}
void loop(){
// Read the pins
int x = readPins();
// Act on returned value
switch (x) {
case 3: // Off
// statements
break;
case 1: // Hi
// statements
break;
case 2: // Med
// statements
break;
case 16: // Low
// statements
break;
case 19: // Strobe
// statements
break;
default: // Any other value, do nothing
// statements
break;
}
}
int readPins(){
int result = 0; // Setup result register
for (int a=0;a<5;a++){ // Index through array
int x=digitalRead(Input_Pins[a]); // Read pin state
result=result << 1; // Rotate result register
result = result | x; // OR pinstate into bit 0
}
return result; // Return
}