/**
EJEMPLO DE ENTRADAS DIGITALES 2
EJEMPLO ON/OFF LED CON 2 BOTONES, EN ESTE EJEMPLO SE ENCIENDE EL LED
CON UN BOTON Y SE APAGA CON OTRO BOTON DISTINTO, EL LED PERMANECE EN
EL ESTADO CORRESPONDIENTE AL ULTIMO BOTON ENCENDIDO.
*/
// ASIGNACION DE PINES
const int pinon = 2;
const int pinoff = 3;
const int pinled = 13;
// VARIABLES DE ESTADO DE BOTONES
int estaon = HIGH;
int estaoff = HIGH;
void setup() {
// CONFIGURAR PINES COMO ENTRADAS
pinMode(pinon, INPUT);
pinMode(pinoff, INPUT);
// CONFIGURAR PIN DE LED COMO SALIDA
pinMode(pinled, OUTPUT);
}
void loop() {
// LEER EL ESTADO DE PINES DE BOTON A VARIABLES
estaon = digitalRead(pinon);
estaoff = digitalRead(pinoff);
if (estaon == LOW) {
digitalWrite(pinled, HIGH);
}
if (estaoff == LOW) {
digitalWrite(pinled, LOW);
}
}