#include <Keypad.h>
#include <LiquidCrystal.h>
//Inicializamos los pines conectados de la pantalla de cristal liquido al esp32
LiquidCrystal lcd(22,23,5,18,19,21);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
byte rowPins[ROWS] = {32, 33, 25, 26}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {27, 14, 12, 13}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char key;
int dato;
int valor = 0;
int boton=1;
char Captura;
int pos =13;
char valor1[6];
byte Indice=0;
void setup()
{
lcd.begin(16,2);
lcd.setCursor(2,0);
lcd.print("BIENVENIDOS");
delay(3000);
lcd.clear();
lcd.setCursor(1,1);
lcd.print("selecc el menu");
delay(3000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("1.nivel");
lcd.setCursor(0,1);
lcd.print("2.temp");
lcd.setCursor(13,1);
lcd.print("3.>");
key = keypad.getKey();
if (key)
{
if(key == '1')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RELE TEMP >1");
lcd.setCursor(14,1);
lcd.print("#<");
lcd.setCursor(14,0);
lcd.print("*>");
delay(100);
dato = 1;
while(dato)
{
key = keypad.getKey();
if(key == '1')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("INGRESE EL % DE");
lcd.setCursor(0,1);
lcd.print("RUN DEL RELE:");}
key=0;
key = keypad.getKey();
if (key!='A'&&key!='B'&&key!='C'&&key!='D'&&key!='#'){
Captura=key;
}
if(Captura&& pos<16){
lcd.setCursor(pos,1);
lcd.print(Captura);
valor1[Indice]=Captura;
lcd.setCursor(pos+1,1);
lcd.print("%");
Indice++;
pos=pos+1;
}
}
//dato
switch(key){
case 'A':
lcd.clear();
lcd.setCursor(0,0);
lcd.print("GUARDANDO");
delay(1000);
while(keypad.getKey()!='B'){
lcd.setCursor(0,0);
lcd.print("VALOR GUARDADO");
lcd.setCursor(0,1);
lcd.print(valor1);
lcd.setCursor(3,1);
lcd.print("% de nivel");
Indice=0;
pos=13;
}
break;
if(key == '3')
{
dato = 0;
lcd.clear();
lcd.setCursor(0,3);
lcd.print("RETORNANDO MENU");
delay(2000);
lcd.clear();
key = 0;
}
}
// }
//////////////////////////////////
if(key == '2')
{
lcd.clear();
dato = 1;
while(dato)
{
lcd.setCursor(0,0);
lcd.print("RELE NIVEL>2");
lcd.setCursor(0,1);
lcd.print("press # volver");
key = keypad.getKey();
if(key == '#')
{
dato = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RETORNANDO");
// delay(100);
lcd.clear();
//return;
key = 0;
}
for(int i=0;i<3; i++)
{
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
}
}
}
//////
if(key == '3')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("programa creado por");
lcd.setCursor(0,1);
lcd.print("editronikx 2022");
lcd.setCursor(0,3);
lcd.print("SUSCRIBETE...");
delay(4000);
lcd.clear();
}
}
}}