Documente Academic
Documente Profesional
Documente Cultură
h>
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Key.h>
byte rowPins[ROWS] = {13, 12, 11, 10}; // connect to the row pinout of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; // connect to the column pinout of the keypad
char key;
char prev_key;
long temp;
#define LUZ1 5
#define LUZ2 4
#define LUZ3 3
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
pinMode(LUZ1, OUTPUT);
pinMode(LUZ2, OUTPUT);
pinMode(LUZ3, OUTPUT);
inicio();
}
void loop() {
// put your main code here, to run repeatedly:
key = kpd.getKey();
if(key != NO_KEY){
switch (key) {
case 'A':
//secuencia A
lcd.clear();
lcd.print("Opcion A elegida");
semaforo(10000, 5000, 10000);
break;
case 'B':
//secuencia B
lcd.clear();
lcd.print("Opcion B elegida");
semaforo(15000, 10000, 15000);
break;
case 'C':
//secuencia C
lcd.clear();
lcd.print("Opcion C elegida");
semaforo(20000, 15000, 20000);
break;
case 'D':
//secuencia D
abortar:
digitalWrite(LUZ1, LOW);
digitalWrite(LUZ2, LOW);
digitalWrite(LUZ3, LOW);
lcd.clear();
lcd.print("Opcion D elegida");
lcd.setCursor(0,1);
lcd.print("Detenido!");
break;
default:
//cualquier otro boton
lcd.clear();
lcd.print("Seleccion");
lcd.setCursor(0,1);
lcd.print("invalida!");
delay(1000);
key = NO_KEY;
inicio();
break;
}
}
}
void inicio() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Seleccione una");
lcd.setCursor(0,1);
lcd.print("opcion: A,B,C");
}