boolean butt_flag = 0;
boolean led_flag;
boolean b1;
boolean l1 = 0;
unsigned long last_press;
void setup() {
// put your setup code here, to run once:
pinMode(12, OUTPUT);
pinMode(11, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
boolean b1 = !digitalRead(11);
if (b1 == HIGH && butt_flag == LOW && millis() - last_press > 150) {
butt_flag = HIGH;
l1 = !l1;
Serial.println("pressed");
last_press = millis();
}
if (b1 == LOW && butt_flag == HIGH) {
butt_flag = LOW;
Serial.println("released");
}
digitalWrite(12, l1);
}