const int led = 2;
const int boton = 8;
int botonState = 0;
int ledState = 0;
int estadoResul = 0;
int contador = 0;
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(led, OUTPUT);
pinMode(boton, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
botonState = digitalRead(boton);
ledState = digitalRead(led);
delay(500);
Serial.print(ledState);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (botonState == HIGH) {
if (ledState = 0) {
contador = 1;
} else {
contador = 1;
}
digitalWrite(led, contador);
} else if (botonState == LOW) {
if (contador = 1) {
estadoResul = 1;
} else {
estadoResul = 0;
}
digitalWrite(led, estadoResul);
}
}