Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keypad.h>
- #include <LiquidCrystal.h>
- const byte ROWS = 4; // Cuatro Filas
- const byte COLS = 4; // Cuatro Columnas
- LiquidCrystal lcd(A0, A1, A2, A3, A4, 1); //Definimos los pines del LCD
- char X;
- char B[6];
- char C[6]= "0497#"; // CLAVE
- byte D = 0;
- int E = 0;
- int ledv = 13;
- int ledr = 12;
- int estado = 0;;
- // Definimos el Keymap
- char keys[ROWS][COLS] = {
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'*','0','#','D'}
- };
- byte rowPins[ROWS] = { 9,8,7,6 }; // Pines conectados al Arduino
- byte colPins[COLS] = { 5,4,3,2,}; // Pines conectados al Arduino
- Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
- void setup(){
- lcd.begin(16, 2);
- digitalWrite(ledv, LOW);
- pinMode(13, OUTPUT);
- pinMode(12, OUTPUT);
- pinMode(A5,INPUT);
- }
- void loop(){
- X = keypad.getKey();
- if(X){
- B[D]= X;
- D ++;
- }
- if(D==0){
- lcd.setCursor(0,0);
- lcd.print( "Bloqueado" );
- }
- if(D==1){
- lcd.setCursor(6,1);
- lcd.print( "*---" );
- }
- if(D==2){
- lcd.setCursor(6,1);
- lcd.print( "**--" );
- }
- if(D==3){
- lcd.setCursor(6,1);
- lcd.print( "*-" );
- }
- if(D==4){
- lcd.setCursor(6,1);
- lcd.print( "**" );
- }
- if((D>=5) && (X =='#')){
- if(!strcmp(B,C)){
- lcd.setCursor(0,0);
- lcd.print("Acceso concedido");
- delay(1000);
- digitalWrite(ledv, HIGH);
- delay(1200);
- digitalWrite(ledv, LOW);
- lcd.clear();
- lcd.setCursor(3,0);
- lcd.print("1 Distancia");
- lcd.setCursor(3,1);
- lcd.print("2 Temperatura");
- }
- else
- {
- lcd.setCursor(0,0);
- lcd.print("Incorrecto");
- delay(1000);
- digitalWrite(ledr, HIGH);
- delay(1200);
- digitalWrite(ledr, LOW);
- E++;
- D=0;
- lcd.setCursor(0,1);
- lcd.print(" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement