it does not like the layout of the int command warning only initialized variables can be placed into program memory area
// List of input pins to read
const int Input_Pins [7] = {
3,4,5,6,7};
void setup(){
// set list of pins to input
for (int a=0;a<7;a++){
pinMode(Input_Pins[a],INPUT);
}
}
void loop(){
// Read the pins
int x = readPins();
// Act on returned value
switch (x) {
case 0: // 12 O'Clock
// statements
break;
case 90: // 3 O'Clock
// statements
break;
case 180: // 6 O'Clock
// statements
break;
case 270: // 9 O'Clock
// statements
break;
default: // Any other value, do nothing
// statements
break;
}
}
int readPins(){
int result = 0; // Setup result register
for (int a=0;a<7;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
}
Moderator edit: [code] ... [/code] tags added. (Nick Gammon)