#define LED 11
#define SWITCH 5
int statoPrecPulsante = LOW;
int statoLED = LOW;
void setup() {
// put your setup code here, to run once:
pinMode (LED, OUTPUT);
pinMode (SWITCH, INPUT);
}
void loop() {
// put your main code here, to run repeatedl
int statoPulsante = digitalRead(SWITCH);
if ((statoPrecPulsante == LOW) && (statoPulsante == HIGH))
{
statoLED = !statoLED;
}
statoPrecPulsante = statoPulsante;
if (statoLED == HIGH)
{
digitalWrite(LED, HIGH);
}
else
{
digitalWrite(LED, LOW);
}
}