0% found this document useful (0 votes)
23 views

Programacion Arduino.

The document describes code for an Arduino project that uses a servo motor, LCD display and keypad to control access through a door. It defines variables and functions for initializing components, reading keypad input, and displaying output to open or deny door access based on a 4 digit PIN code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Programacion Arduino.

The document describes code for an Arduino project that uses a servo motor, LCD display and keypad to control access through a door. It defines variables and functions for initializing components, reading keypad input, and displaying output to open or deny door access based on a 4 digit PIN code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

//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(){

myservo.attach(0); //Ser en pin 0

lcd.clear(); // limpiar pantalla

lcd.begin(16, 2); // Iniciar lcd

lcd.print(" PIN");

lcd.setCursor(0, 1);

lcd.print(" -*** ");

myservo.write(mot_min);

void loop(){

char customKey = customKeypad.getKey();

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]= '*';

Str[10]= ' ';

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]= '*';

Str[10]= ' ';

lcd.clear();

lcd.setCursor(0,0);

lcd.print(" PIN");

lcd.setCursor(0,1);

lcd.print(Str);

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy