/*
Un pulsador enciende tres led y otro los apaga en secuencia
*/
int buttonPin_i = 7; // the number of the pushbutton pin
int buttonPin_d = 8; // the number of the pushbutton pin
int verde = 13;
int amarillo = 12 ; // the number of the LED pin
int rojo = 11 ; // the number of the LED pin
// variables will change:
int buttonState_i = 0; // variable for reading the pushbutton status
int buttonState_d = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(verde, OUTPUT);
pinMode(amarillo, OUTPUT);
pinMode(rojo, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin_i, INPUT);
pinMode(buttonPin_d, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState_i = digitalRead(buttonPin_i);
buttonState_d = digitalRead(buttonPin_d);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState_i == HIGH)
{
digitalWrite(verde, HIGH);
digitalWrite(amarillo, HIGH);
digitalWrite(rojo, HIGH);
}
if (buttonState_d == HIGH) {
// parpadea LED amarillo
digitalWrite(verde, LOW);
delay(500);
digitalWrite(amarillo, LOW);
delay(500);
digitalWrite(rojo, LOW);
}
}