X-Git-Url: http://git.piffa.net/web?a=blobdiff_plain;f=basic%2Fbuttons%2Fbutton_state_4_state%2Fbutton_state_4_state.ino;fp=basic%2Fbuttons%2Fbutton_state_4_state%2Fbutton_state_4_state.ino;h=a6a4e05e504198c8b1028fee93041107e7cbeab1;hb=e50f2cf8e7402ea56cd01835be9f88c53876bfd1;hp=ef6ae05d4bcda1e7b39351186b982cc9ae434042;hpb=f7cdba7df419dcde095f911daa92deb9dcd283ec;p=sketchbook_andrea diff --git a/basic/buttons/button_state_4_state/button_state_4_state.ino b/basic/buttons/button_state_4_state/button_state_4_state.ino index ef6ae05..a6a4e05 100644 --- a/basic/buttons/button_state_4_state/button_state_4_state.ino +++ b/basic/buttons/button_state_4_state/button_state_4_state.ino @@ -14,16 +14,16 @@ int ledStatus; // varabile per mantenere lo stato del led void setup() { pinMode(buttonPin, INPUT); pinMode(led, OUTPUT); - Serial.begin(9600); // Attiva la comunicazione seriale a 9600bps + Serial.begin(9600); // Attiva la comunicazione seriale a 9600bps ultimoStato = digitalRead(buttonPin); // Prima lettura del bottone ledStatus = 0; // Il LED viene inpostato come spento } void loop(){ - statoAttuale = digitalRead(buttonPin); // read input value and store it in var + statoAttuale = digitalRead(buttonPin); // Legge lo stato del bottone e lo resistra in val delay(20); // riduce l'effetto bounce if (statoAttuale != ultimoStato) { // lo stato del bottone e' cambiato - if (statoAttuale == HIGH) { // il bottone e' stato provato + if (statoAttuale == HIGH) { // il bottone e' stato premuto Serial.println("Button premuto"); ledStatus = !ledStatus ; // Inverte lo stato del LED @@ -34,7 +34,7 @@ void loop(){ } } - ultimoStato = statoAttuale; // save the new state in our variable + ultimoStato = statoAttuale; // Aggiorna lo stato finale al valore attuale digitalWrite(led, ledStatus); // setta il led allo stato richiesto }