void setup() {
Serial.begin(9600);
//configure pin 2,3,4 and 5 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
// built in LED
pinMode(13, OUTPUT);
}
void loop() {
//read the pushbutton value into a variable
int sensorVal2 = digitalRead(2);
int sensorVal3 = digitalRead(3);
int sensorVal4 = digitalRead(4);
int sensorVal5 = digitalRead(5);
//print out the value of the pushbutton
Serial.print("Button state: ");
Serial.print(sensorVal2);
Serial.print(sensorVal3);
Serial.print(sensorVal4);
Serial.print(sensorVal5);
Serial.print('\n');
// Keep in mind the pull-up means the pushbutton's logic is inverted. It goes
// HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the
// button's pressed, and off when it's not:
if (sensorVal2 == LOW or sensorVal3 == LOW or sensorVal4 == LOW or sensorVal5 == LOW) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
delay(200);
}