This Project given with all accesories & power adapter with tested  - schematics and code given below  


Working Explanation:

This system mainly contains AT89S52 microcontroller, keypad module, buzzer and LCD. At89s52 microcontroller controls the complete processes like taking password form keypad module, comparing passwords predefined password, driving buzzer and send status to LCD display. Keypad is used for inserting password into the microcontroller. Buzzer is used for indication of wrong password and LCD is used for displaying status or messages on it. Buzzer has inbuilt driver by using a NPN transistor.



Circuit Explanation:

Circuit diagram for this Digital lock using 8051 has been shown below and can easily be understood. Keypad module’s Column pins are directly connected to pin P0.0, P0.1, P0.2, P0.3 and Row pins are connected to P0.4, P0.5, P0.6, P0.7 of 89s52 microcontroller’s port 0. A 16x2 LCD is connected with 89s52 microcontroller in 4-bit mode. Control pin RS, RW and En are directly connected to pin P1.0, GND and P1.2. And data pin D4-D7 is connected to pins P1.4, P1.5, P1.6 and P1.7 of 89s52. And one buzzer is connected at pin P2.6 through a resistor.



In this circuit we have used multiplexing technique to interface keypad to the 8051 microcontroller, for entering the password in the system. Here we are using a 4x4 keypad which has 16 keys. If we want to use 16 keys then we need 16 pin for connection to 89s52, but in multiplexing technique we need to use only 8 pins for interfacing 16 keys. So that it is a smart way to interface the keypad module.


Multiplexing technique is a very efficient way to reduce number of pins used with the microcontroller for providing the input or password. Basically this technique is used in two ways - one is row scanning and other one is column scanning.

 Here we are going to explain row scanning:

First we have to define 8 pin for keypad module. In which first 4 pins are column and last 4 pins are rows.


Program Explanation:

We have used a predefined password in the program, this password can be defined by the user in the code below. When user enters a password to the system, then system compares the user entered password with stored or predefined password in Code of Program. If a match occurs then LCD will show “Access Grated” and if the password doesn’t match then LCD will show “Access Denied” and buzzer will continuously beep for some time. Here we have used string.h library. By using this library we can compare or match two strings, by using “strncmp” function.

In the program, first of all we include header file and defines variable and  input & output pins for keypad and LCD.



#include<reg51.h>
#include<string.h>
#define lcdport P1

sbit col1=P0^0;
sbit col2=P0^1;
sbit col3=P0^2;
sbit col4=P0^3;
sbit row1=P0^4;
sbit row2=P0^5;
sbit row3=P0^6;
sbit row4=P0^7;

sbit rs=P1^0;
sbit en=P1^2;
sbit buzzer=P2^6;

char pass[4],i=0;

void delay(int itime)
{
    int i,j;
    for(i=0;i<itime;i++)
    for(j=0;j<1275;j++);
}

void daten()
{
    rs=1;
    en=1;
    delay(5);
    en=0;
}

void lcddata(unsigned char ch)
{
    lcdport=ch & 0xf0;
    daten();
    lcdport=(ch<<4) & 0xf0;
    daten();
}

void cmden(void)
{
    rs=0;
    en=1;
    delay(5);
    en=0;
}

void lcdcmd(unsigned char ch)
{
    lcdport=ch & 0xf0;
    cmden();
    lcdport=(ch<<4) & 0xf0;
    cmden();
}

void lcdstring(char *str)
{
    while(*str)
    {
        lcddata(*str);
        str++;
    }
}

void lcd_init(void)
{
    lcdcmd(0x02);
    lcdcmd(0x28);
    lcdcmd(0x0e);
    lcdcmd(0x01);
}

void keypad()
{
        int cursor=192,flag=0;
    lcdcmd(1);
    lcdstring("Enter Ur Passkey");
    lcdcmd(0xc0);
    i=0;
    while(i<4)
    {
    flag=cursor;
     col1=0;
     col2=col3=col4=1;
     if(!row1)
     {
        lcddata('1');
        pass[i++]='1';
        cursor++;
        while(!row1);
          }
     
      else if(!row2)
     {
        lcddata('4');
        pass[i++]='4';
        cursor++;
        while(!row2);
        }
     
      else if(!row3)
     {
        lcddata('7');
        pass[i++]='7';
        cursor++;
        while(!row3);
        }
     
      else if(!row4)
     {
        lcddata('*');
        pass[i++]='*';
        cursor++;
        while(!row4);
        }
     
     col2=0;
     col1=col3=col4=1;
     if(!row1)
     {
        lcddata('2');
        pass[i++]='2';
        cursor++;
        while(!row1);
        }
     
      else if(!row2)
     {
        lcddata('5');
        pass[i++]='5';
        cursor++;
        while(!row2);
        }
     
      else if(!row3)
     {
        lcddata('8');
        pass[i++]='8';
        cursor++;
        while(!row3);
        }
     
      else if(!row4)
     {
        lcddata('0');
        pass[i++]='0';
        cursor++;
        while(!row4);
        }
     
     col3=0;
     col1=col2=col4=1;
     if(!row1)
     {
        lcddata('3');
        pass[i++]='3';
        cursor++;
        while(!row1);
        }
     
      else if(!row2)
     {
        lcddata('6');
        pass[i++]='6';
        cursor++;
        while(!row2);
        }
     
      else if(!row3)
     {
        lcddata('9');
        pass[i++]='9';
        cursor++;
        while(!row3);
        }
     
      else if(!row4)
     {
        lcddata('#');
        pass[i++]='#';
        cursor++;
        while(!row4);
        }
     
      col4=0;
     col1=col3=col2=1;
     if(!row1)
     {
        lcddata('A');
        pass[i++]='A';
        cursor++;
        while(!row1);
        }
     
      else if(!row2)
     {
        lcddata('B');
        pass[i++]='B';
        cursor++;
        while(!row2);
        }
     
      else if(!row3)
     {
        lcddata('C');
        pass[i++]='C';
        cursor++;
        while(!row3);
        }
     
      else if(!row4)
     {
        lcddata('D');
        pass[i++]='D';
        cursor++;
        while(!row4);
          }
     if(i>0)
     {
         if(flag!=cursor)
         delay(100);
         lcdcmd(cursor-1);
         lcddata('*');
     } 
 }      
}

void accept()
{
     lcdcmd(1);
     lcdstring("Welcome");
     lcdcmd(192);
     lcdstring("Password Accept");
     delay(200);
}

void wrong()
{
    buzzer=0;
    lcdcmd(1);
     lcdstring("Wrong Passkey");
    lcdcmd(192);
    lcdstring("PLZ Try Again");
    delay(200);
    buzzer=1;
}

void main()
{
    buzzer=1;
    lcd_init();
    lcdstring("Electronic Code");
    lcdcmd(0xc0);
    lcdstring("  Lock System  ");
    delay(400);
    lcdcmd(1); 
    lcdstring("Circuit Digest");
    delay(400);
    while(1)
    {
            i=0;
            keypad();
            if(strncmp(pass,"4201",4)==0)
            {
            accept();
            lcdcmd(1);
            lcdstring("Access Granted ");
            delay(300);
                }
        
        else 
        {
           lcdcmd(1);
           lcdstring("Access Denied");
           wrong();
           delay(300);
        }
    }
}



Electronic code lock using 8051 Microcontorller,

  • Product Code: Electronic code lock using 8051 Microcontorller,
  • Availability: In Stock
  • Rs3,750.00


Tags: Electronic code lock using 8051 Microcontorller

Whatsapp