#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
int LED1 = A0;
int LED2 = 10;
int LED3 = 11;
int t1=0;
int t2=0;
int t3=0;
const byte ROWS = 4; //FILAS
const byte COLS = 4; //COLUMNAS
byte rowPins[ROWS] = {9, 8, 7, 6}; //FILAS
byte colPins[COLS] = {5, 4, 3, 2}; //COLUMNAS
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'},
};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
}
void loop()
{
lcd.setCursor(1, 0);
lcd.print(" PRESIONE ");
lcd.setCursor(2, 1);
lcd.print("(1), (2), (3) ");
char Key = customKeypad.getKey();
if(Key=='1')
{
t1=500;
lcd.setCursor(1, 0);
lcd.print("TIEMPO UNO ");
lcd.setCursor(2, 1);
lcd.print(" OK ");
}
if(Key=='2')
{
t2=1000;
lcd.setCursor(1, 0);
lcd.print("TIEMPO DOS ");
lcd.setCursor(2, 1);
lcd.print(" OK ");
}
if(Key=='3')
{
t3=2000;
lcd.setCursor(1, 0);
lcd.print("TIEMPO TRES ");
lcd.setCursor(2, 1);
lcd.print(" OK ");
}
if(Key=='#')
{
t1=0;
t2=0;
t3=0;
lcd.setCursor(1, 0);
lcd.print(" APAGADO ");
lcd.setCursor(2, 1);
lcd.print(" ");
}
analogWrite(LED1, 255);
delay(t1);
analogWrite(LED1, 0);
delay(t1);
analogWrite(LED2, 255);
delay(t2);
analogWrite(LED2, 0);
delay(t2);
analogWrite(LED3, 255);
delay(t3);
analogWrite(LED3, 0);
delay(t3);
}