pugliasos newlogoDEF

Orario della segreteria: tutti i martedì, dalle ore 17 alle 19, su appuntamento.


Prima proposta (con due variabili char)

 

   Memorizzeremo lo stato del LED e del pulsante, rispettivamente nelle variabile statoLED e statoPulsante ambedue di tipo char inizializzate con il valore “false” ossia 0.

int led = 13;
int pulsante = 2;
char statoLED = 0;
char statoPulsante = 0;

void setup() {
  pinMode(led, OUTPUT);
  pinMode(pulsante, INPUT);
}

void loop() {
  statoPulsante = digitalRead(pulsante);
  if (statoPulsante == HIGH) {
    if (statoLED == 0) {
      digitalWrite(led, 1);
      statoLED = 1;
    }
    else {
      digitalWrite(led, 0);
      statoLED = 0;
    }
  }
delay(250);
}

Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline