2 Interrupts : input deboounce
4 Utilizzare un interrupt per intercettare
5 l'input di un interruttore momentaneo.
7 Debounce software nella funzione richiamata.
8 Per debounce hardware: http://www.all-electric.com/schematic/debounce.htm
13 volatile int state = LOW;
17 pinMode(ledPin, OUTPUT);
18 pinMode(2, INPUT_PULLUP);
19 attachInterrupt(0, blink, FALLING);
24 //digitalWrite(ledPin, state);
25 delay(10000); // Mette in pausa Arduino per 10sec
30 // Modifica dello stato del LED
32 static unsigned long last_interrupt_time = 0;
33 // If interrupts come faster than 200ms, assume it's a bounce and ignore
34 if (millis() - last_interrupt_time > 200)
35 { // Azione da intraprendere
37 digitalWrite(ledPin, state);
39 last_interrupt_time = millis();