byte tombol = 2;
bool data_tombol = 1;
#define ditekan 1
bool hold_tombol = 1;
int hitung = 100;
void setup() {
// put your setup code hgere, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(tombol, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
data_tombol = digitalRead(tombol);
if (data_tombol==1){
if (hold_tombol==ditekan) {
hitung -= 1;
Serial.print("dipejet ke: ");
Serial.println(hitung);
delay(500);
hold_tombol = 0;
}
} else {
hold_tombol = 1;
}
}