Examen Informatica
Examen Informatica
h>
LiquidCrystal lcd (7,8,9,10,11,12);
const int Led1 = 2;
const int Led2 = 3;
const int Led3 = 4;
const int Boton1 = 6;
const int Boton2 = 1;
int Lectura1;
int Lectura2;
void setup()
{
pinMode(Boton1, INPUT);
pinMode(Boton2, INPUT);
pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);
pinMode(Led3, OUTPUT);
lcd.begin(16,2);
}
void loop()
{
Lectura1 = digitalRead (Boton1);
Lectura2 = digitalRead (Boton2);
if (Lectura1 == 1 && Lectura2 == 0){
digitalWrite (Led1, HIGH);
lcd.setCursor(0,0);
lcd.print("Led Rojo ON ");
lcd.setCursor(0,1);
lcd.print("Led Verde OFF");
}
if (Lectura1 == 0 && Lectura2 == 0){
digitalWrite (Led1, LOW);
lcd.setCursor(0,0);
lcd.print("Led Rojo OFF");
digitalWrite (Led2, LOW);
lcd.setCursor(0,1);
lcd.print("Led Verde OFF");
}
if (Lectura2 == 1 && Lectura1 == 0){
digitalWrite (Led2, HIGH);
lcd.setCursor(0,1);
lcd.print("Led Verde ON ");
lcd.setCursor(0,0);
lcd.print("Led Rojo OFF");
}
if (Lectura1 == 1 && Lectura2 == 1){
digitalWrite (Led1, LOW);
digitalWrite (Led2, LOW);
digitalWrite (Led3, HIGH);
lcd.setCursor(0,0);
lcd.print("!!!ALERTA!!!");
lcd.setCursor(0,1);
lcd.print(" ");
}
else{
digitalWrite (Led3, LOW);
}
}