#define LED 2
#define TASTER 3
//bool flag = LOW;
bool Schalter(bool IN) {
static unsigned long millis_alt = millis();
static bool OUT = LOW;
static bool flag = LOW;
if (millis() - millis_alt > 20) {
millis_alt = millis();
if (IN == LOW && flag == LOW) {
OUT = !OUT;
flag = HIGH;
}
if (IN == HIGH) {
flag = LOW;
}
}
return OUT;
}
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(TASTER, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
bool tstr = Schalter(digitalRead(TASTER));
digitalWrite(LED, tstr);
}