Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michaelsarduino/85a5f23996f7f465cfea to your computer and use it in GitHub Desktop.
Save michaelsarduino/85a5f23996f7f465cfea to your computer and use it in GitHub Desktop.
const int button = 12; // Button Pin
const int led = 13; // LED Pin
int led_status = HIGH;
int button_status;
int vorheriger_button_status = LOW;
long letztes_prellen = 0;
long entprellzeit = 60;
void setup() {
pinMode(button, INPUT);
pinMode(led, OUTPUT);
digitalWrite(led, led_status);
}
void loop() {
int aktueller_status = digitalRead(button);
if (aktueller_status != vorheriger_button_status) {
letztes_prellen = millis();
}
if ((millis() - letztes_prellen) > entprellzeit) {
if (aktueller_status != button_status) {
button_status = aktueller_status;
if (button_status == LOW) {
led_status = !led_status;
}
}
}
digitalWrite(led, led_status);
vorheriger_button_status = aktueller_status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment