#include <Arduino.h>
const int INPUT_EX_1 = 8; // Pin for button 1
const int INPUT_EX_2 = 9; // Pin for button 2
unsigned long previousMillis = 0; // Used to store the last time the state was checked
const unsigned long debounceDelay = 200; // Interval for checking button states in milliseconds
void setup() {
Serial.begin(9600);
pinMode(INPUT_EX_1, INPUT_PULLUP); // Set button 1 pin as input with internal pull-up
pinMode(INPUT_EX_2, INPUT_PULLUP); // Set button 2 pin as input with internal pull-up
}
void loop() {
unsigned long currentMillis = millis();
// Only check button states at set intervals
if (currentMillis - previousMillis >= debounceDelay) {
previousMillis = currentMillis;
// Check for button press states and print accordingly
if (!digitalRead(INPUT_EX_1) && !digitalRead(INPUT_EX_2)) {
while (!digitalRead(INPUT_EX_1) && !digitalRead(INPUT_EX_2));
Serial.println("Input 11");
}
else if (!digitalRead(INPUT_EX_1)) {
while (!digitalRead(INPUT_EX_1));
Serial.println("Input 01");
}
else if (!digitalRead(INPUT_EX_2)) {
while (!digitalRead(INPUT_EX_2));
Serial.println("Input 10");
}
}
}