int button = 14;
int count = 0;
long countMillis = 0;
void setup() {
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(button, INPUT_PULLUP);
}
void loop() {
if (digitalRead(button) == LOW) {
count = count + 1;
delay(200);
}
if (millis() - countMillis > 5000) {
countMillis = millis();
if (count > 3) {
Serial.println("TEST");
count = 0;
delay(1000);
} else {
count = 0;
}
}
Serial.print("Count: ");
Serial.println(count);
Serial.print("Millis: ");
Serial.println(millis());
delay(10); // this speeds up the simulation
}