//incluir librerias.
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
int mot_min = 0; //servo inicio
int mot_max = 180; // Servo abre
int character = 0;
int activated =0;
char Str[16] = {' ', ' ', ' ', ' ', ' ', ' ', '-', '*', '*', '*', ' ', ' ', ' ', ' ', ' ', ' '};
//variables
Servo myservo;
LiquidCrystal lcd(13, A0, 12, 11, 10, 9); // ( RS, EN, d4, d5, d6, d7)
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1','4','7','*'},
{'2','5','8','0'},
{'3','6','9','#'},
{'A','B','C','D'}
};
byte rowPins[ROWS] = {4, 3, 2, 1};
byte colPins[COLS] = {8, 7, 6, 5};
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
[Link](0); //Ser en pin 0
[Link](); // limpiar pantalla
[Link](16, 2); // Iniciar lcd
[Link](" PIN");
[Link](0, 1);
[Link](" -*** ");
[Link](mot_min);
void loop(){
char customKey = [Link]();
if(customKey){
if (character == 0){
[Link](customKey);
Str[6]= customKey;
[Link]();
[Link](0,0);
[Link](" PIN");
[Link](0,1);
[Link](Str);
if (character == 1){
[Link](customKey);
Str[7]= customKey;
[Link]();
[Link](0,0);
[Link](" PIN");
[Link](0,1);
[Link](Str);
if (character == 2){
[Link](customKey);
Str[8]= customKey;
[Link]();
[Link](0,0);
[Link](" PIN");
[Link](0,1);
[Link](Str);
if (character == 3){
[Link](customKey);
Str[9]= customKey;
[Link]();
[Link](0,0);
[Link](" PIN");
[Link](0,1);
[Link](Str);
if (character ==4){
[Link](customKey);
Str[10]= customKey;
activated=1;
character=character+1;
}
if (activated == 1){
if(Str[10]='A' && character==5 && Str[6]=='2' && Str[7]=='4' && Str[8]=='2' && Str[9]=='0' ){
[Link](mot_max);
[Link]();
[Link](4,0);
[Link]("ACEPTADO");
activated = 2;
delay(1000);
[Link]();
[Link](4,0);
[Link]("BIENVENIDO");
delay(500);
[Link](2,1);
[Link]("ERVIN POZ");
delay(1000);
[Link]();
[Link](1,0);
[Link]("PUERTA ABIERTA");
}else{
[Link]();
[Link](1,0);
[Link]("ERROR INTENTE");
[Link](3,1);
[Link]("NUEVAMENTE");
delay(3000);
character=0;
Str[6]= '-';
Str[7]= '*';
Str[8]= '*';
Str[9]= '*';
Str[10]= ' ';
activated = 0;
[Link]();
[Link](0,0);
[Link](" PIN");
[Link](0,1);
[Link](Str);
if (activated == 2){
if(customKey == 'B' ) {
[Link](mot_min);
activated = 0;
character=0;
Str[6]= '-';
Str[7]= '*';
Str[8]= '*';
Str[9]= '*';
Str[10]= ' ';
[Link]();
[Link](0,0);
[Link](" PIN");
[Link](0,1);
[Link](Str);
}
}