Código Arduino Botonera 4 Pulsadores:
/*** Global variables ***/
int Boton1=0;
int Boton2=0;
int Reset=0;
int Boton3=0;
int Boton4=0;
/*** Function declaration ***/
void setup()
{
pinMode(2,INPUT);
pinMode(3,OUTPUT);
pinMode(4,INPUT);
pinMode(5,OUTPUT);
pinMode(7,INPUT);
pinMode(6,OUTPUT);
pinMode(9,INPUT);
pinMode(8,OUTPUT);
pinMode(10,INPUT);
}
void loop()
{
if (digitalRead(2) == HIGH) {
if (Boton1 == 0 == Boton2 == 0 == Boton3 == 0 == Boton4 == 0) {
digitalWrite(3,HIGH);
delay(500);
Boton1=1;
Reset=0;
Boton3=0;
Boton4=0;
Boton2=0;
}
}
if (digitalRead(4) == HIGH) {
if (Boton2 == 0 == Boton1 == 0 == Boton3 == 0 == Boton4 == 0) {
digitalWrite(5,HIGH);
delay(500);
Boton2=1;
Reset=0;
Boton3=0;
Boton4=0;
Boton1=0;
}
}
if (digitalRead(7) == HIGH) {
if (Boton3 == 0 == Boton1 == 0 == Boton2 == 0 == Boton4 == 0) {
digitalWrite(6,HIGH);
delay(500);
Boton3=1;
Reset=0;
Boton4=0;
Boton1=0;
Boton2=0;
}
}
if (digitalRead(9) == HIGH) {
if (Boton4 == 0 == Boton1 == 0 == Boton2 == 0 == Boton3 == 0) {
digitalWrite(8,HIGH);
delay(500);
Boton4=1;
Boton3=0;
Boton2=0;
Boton1=0;
Reset=0;
}
}
if (digitalRead(10) == HIGH) {
if (Reset == 0) {
digitalWrite(3,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(8,LOW);
delay(500);
Reset=1;
Boton1=0;
Boton2=0;
Boton3=0;
Boton4=0;
}
}
}
/*** Function definition ***/