Programacion Arduino.
Programacion Arduino.
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
int character = 0;
char Str[16] = {' ', ' ', ' ', ' ', ' ', ' ', '-', '*', '*', '*', ' ', ' ', ' ', ' ', ' ', ' '};
//variables
Servo myservo;
LiquidCrystal lcd(13, A0, 12, 11, 10, 9); // ( RS, EN, d4, d5, d6, d7)
char hexaKeys[ROWS][COLS] = {
{'1','4','7','*'},
{'2','5','8','0'},
{'3','6','9','#'},
{'A','B','C','D'}
};
lcd.print(" PIN");
lcd.setCursor(0, 1);
myservo.write(mot_min);
void loop(){
if(customKey){
if (character == 0){
Serial.println(customKey);
Str[6]= customKey;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" PIN");
lcd.setCursor(0,1);
lcd.print(Str);
if (character == 1){
Serial.println(customKey);
Str[7]= customKey;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" PIN");
lcd.setCursor(0,1);
lcd.print(Str);
if (character == 2){
Serial.println(customKey);
Str[8]= customKey;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" PIN");
lcd.setCursor(0,1);
lcd.print(Str);
if (character == 3){
Serial.println(customKey);
Str[9]= customKey;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" PIN");
lcd.setCursor(0,1);
lcd.print(Str);
if (character ==4){
Serial.println(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' ){
myservo.write(mot_max);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ACEPTADO");
activated = 2;
delay(1000);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("BIENVENIDO");
delay(500);
lcd.setCursor(2,1);
lcd.print("ERVIN POZ");
delay(1000);
lcd.clear();
lcd.setCursor(1,0);
lcd.print("PUERTA ABIERTA");
}else{
lcd.clear();
lcd.setCursor(1,0);
lcd.print("ERROR INTENTE");
lcd.setCursor(3,1);
lcd.print("NUEVAMENTE");
delay(3000);
character=0;
Str[6]= '-';
Str[7]= '*';
Str[8]= '*';
Str[9]= '*';
activated = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" PIN");
lcd.setCursor(0,1);
lcd.print(Str);
if (activated == 2){
if(customKey == 'B' ) {
myservo.write(mot_min);
activated = 0;
character=0;
Str[6]= '-';
Str[7]= '*';
Str[8]= '*';
Str[9]= '*';
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" PIN");
lcd.setCursor(0,1);
lcd.print(Str);
}
}