Untitled
unknown
plain_text
8 months ago
405 B
4
Indexable
const uint8_t buttonPins[] = {2, 3, 4, 5};
void setup() {
Serial.begin(9600);
for (int i = 0; i < 4; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
}
void loop() {
for (int i = 0; i < 4; i++) {
if (digitalRead(buttonPins[i]) == LOW) {
Serial.print("Button ");
Serial.print(i + 1);
Serial.println(" is pressed");
delay(200);
}
}
}
Editor is loading...
Leave a Comment