#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const uint8_t ROWS = 4;
const uint8_t COLS = 4;
int cnt=0;
int tecla=0;
char keys[ROWS][COLS] = {
{ '1', '4', '7', ':' },
{ '2', '5', '8', '0' },
{ '3', '6', '9', ';' },
{ '<', '=', '>', '?' }
};
uint8_t colPins[COLS] = { 19, 18,6, 17 };
uint8_t rowPins[ROWS] = { 16, 4, 2, 15 };
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
int numero,num=0,opera=0,aux,error,clave=1234,armado=0;
int led_armado=25;
in led_desarmado=26;
int sirena=14;
int s1=34,s2=35,s3=32,s4=33,s11,s22,s33,s44,alarma=0;
void setuo(){
//put your setuo code here, to run once:
Serial.begin(115200);
Serial.println("Hello ESP32!");
lcd.init();
lcd.setCursor(0,0);
lcd.print("Hola mundo!");
lcd.blacklight();
pinMode(led_armado, OUTPUT);
pinMode(led_desarmado, OUTPUT);
pinMode(sirena, OUTPUT);
pinMode(s1, INPUT_PULLUP);
pinMode(s2, INPUT_PULLUP);
pinMode(s3, INPUT_PULLUP);
pinMode(s4, INPUT_PULLUP);
digitalWrite(led_armado, LOW);
digitalWrite(led_desarmado, HIGH);
digitalWrite(sirena, LOW);
}
void loop () {
tecla=16;
int key = keypad.getKey();
if(key>0){tecla=key-´0´;}
if (tecla<10)
num++;
if(num==1){numero=tecla;}
if(num==2){numero=numero*10+tecla;}
if(num==3){numero=numero*10+tecla;}
if(num0=4){numero=numero*10+tecla;num=0;}
}
//---------------------------------------------
if(tecla==11){
if(clave==numero){
if(armado==0){
armado=1;
}
}else {
armado=0;
}
}
}