int buttonPin1 = 2;
int buttonPin2 = 3; // the number of the pushbutton pin
int buttonPin3 = 4; // the number of the pushbutton pin
int cilPinA = 7; // the number of the LED pin
int cilPinB = 8;
int cilPinC = 9;
int cilPinD = 10;
int cilPinE = 11;
int cilPinF = 12;
// variables will change:
int encender = 0;
int anterior = 0;
int estado = 0;
int encender1 = 0;
int anterior1 = 0;
int estado1 = 0;
int encender2 = 0;
int anterior2 = 0;
int estado2 = 0;
// variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(cilPinA, OUTPUT);
pinMode(cilPinB, OUTPUT);
pinMode(cilPinC, OUTPUT);
pinMode(cilPinD, OUTPUT);
pinMode(cilPinE, OUTPUT);
pinMode(cilPinF, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
//pinMode(buttonPin3, INPUT);
digitalWrite (cilPinA, LOW);
digitalWrite (cilPinB, LOW);
digitalWrite (cilPinC, LOW);
digitalWrite (cilPinD, LOW);
digitalWrite (cilPinE, LOW);
digitalWrite (cilPinF, LOW);
}
void loop() {
extendActuador1();
delay(50);
extendActuador2();
delay(50);
extendActuador3();
delay(50);
}
void extendActuador1(){
// read the state of the pushbutton value:
estado = digitalRead(buttonPin1);
estado1 = digitalRead(buttonPin2);
estado2 = digitalRead(buttonPin3);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (estado && anterior == 0) {
// turn LED on:
encender = 1 - encender;
delay (300);
digitalWrite(cilPinB,LOW);
delay(250);
digitalWrite(cilPinA,HIGH);
digitalWrite(cilPinB, LOW);
delay(250);
digitalWrite(cilPinB,HIGH);
delay(250);
digitalWrite(cilPinA,LOW);
digitalWrite(cilPinB,LOW);
}
}
void extendActuador2(){
// read the state of the pushbutton value:
estado = digitalRead(buttonPin1);
estado1 = digitalRead(buttonPin2);
estado2 = digitalRead(buttonPin3);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (estado1 && anterior1 == 0) {
// turn LED on:
encender1 = 1 - encender1;
delay (300);
digitalWrite(cilPinD,LOW);
delay(250);
digitalWrite(cilPinC,HIGH);
digitalWrite(cilPinD, LOW);
delay(250);
digitalWrite(cilPinD,HIGH);
delay(250);
digitalWrite(cilPinC,LOW);
digitalWrite(cilPinD,LOW);
}
}
void extendActuador3(){
// read the state of the pushbutton value:
estado = digitalRead(buttonPin1);
estado1 = digitalRead(buttonPin2);
estado2 = digitalRead(buttonPin3);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (estado2 && anterior2 == 0) {
// turn LED on:
encender2 = 1 - encender2;
delay (300);
digitalWrite(cilPinF,LOW);
delay(250);
digitalWrite(cilPinE,HIGH);
digitalWrite(cilPinF, LOW);
delay(250);
digitalWrite(cilPinF,HIGH);
delay(250);
digitalWrite(cilPinE,LOW);
digitalWrite(cilPinF,LOW);
}
}