top of page
Writer's pictureSanskruti Ashtikar

Door Access Control System Using 8051 Microcontroller

Updated: 3 days ago

Introduction


Access control systems are widely used for security purposes in homes, offices, and other buildings. These systems allow only authorized individuals to enter restricted areas. In this project, we will design a door access control system using the 8051 microcontroller and a keypad for input.





Components Required


  • 8051 Microcontroller (e.g., AT89S52)

  • 4x4 Keypad

  • 16x2 LCD Display

  • Relay Module (to control the door lock)

  • Buzzer (for incorrect access alert)

  • Resistors (10kΩ, 1kΩ, 330Ω)

  • Capacitors (33pF, 100μF)

  • Crystal Oscillator (11.0592 MHz)

  • Breadboard and Connecting Wires

  • Power Supply (5V for the 8051 and components)


Circuit Diagram


The keypad is used to enter a password, which is checked against a predefined code stored in the microcontroller. If the entered password is correct, the relay is activated to unlock the door. The LCD displays status messages, and a buzzer sounds if an incorrect password is entered.


+5V ----- +5V
          |
          |
       Keypad
        +---+
        |   |
        |   |
        |   +---------- P1.0 - P1.3 (8051 rows)
        |   +---------- P1.4 - P1.7 (8051 columns)
        |   |
        GND
LCD Display
    VSS to Ground
    VCC to +5V
    VEE to Potentiometer (for contrast control)
    RS  to P2.0 (8051)
    RW  to Ground
    E   to P2.1 (8051)
    D4  to P2.2 (8051)
    D5  to P2.3 (8051)
    D6  to P2.4 (8051)
    D7  to P2.5 (8051)
Relay Module
    VCC to +5V
    GND to Ground
    IN to P3.0 (8051)
    NO to one terminal of the door lock
    COM to power supply for the lock
Buzzer
    Anode to P3.1 (8051) through 330Ω resistor
    Cathode to Ground




Pin Connections


  • Keypad:

  • Rows connected to P1.0 to P1.3 of the 8051

  • Columns connected to P1.4 to P1.7 of the 8051

  • LCD Display:

  • VSS to Ground

  • VCC to +5V

  • VEE to the potentiometer for contrast control

  • RS to P2.0 of the 8051

  • RW to Ground

  • E to P2.1 of the 8051

  • D4 to P2.2 of the 8051

  • D5 to P2.3 of the 8051

  • D6 to P2.4 of the 8051

  • D7 to P2.5 of the 8051

  • Relay Module:

  • VCC to +5V

  • GND to Ground

  • IN connected to P3.0 of the 8051

  • Buzzer:

  • Anode connected to P3.1 of the 8051 through a 330Ω resistor

  • Cathode connected to Ground


Software Implementation


The code is written in C using Keil uVision IDE. It involves reading the keypad input, comparing it with a predefined password, and controlling the relay and buzzer based on the input.


#include <reg51.h>
#include <lcd.h> // Include a custom LCD library
#define PASSWORD "1234" // Predefined password
sbit RELAY = P3^0; // Relay control pin
sbit BUZZER = P3^1; // Buzzer control pin
unsigned char keypad[4][4] = {{'1','2','3','A'},
                              {'4','5','6','B'},
                              {'7','8','9','C'},
                              {'*','0','#','D'}};
unsigned char row, col;
void delay(unsigned int time) {
    unsigned int i, j;
    for(i = 0; i < time; i++)
        for(j = 0; j < 1275; j++);
}
void keypad_init() {
    P1 = 0xF0; // Set P1.0-P1.3 as inputs (rows) and P1.4-P1.7 as outputs (columns)
}


char keypad_getkey() {
    while(1) {
        for(col = 0; col < 4; col++) {
            P1 = ~(0x10 << col); // Ground one column at a time
            row = P1 & 0x0F; // Read the rows
            if (row != 0x0F) {
                while(P1 & (0x10 << col)); // Wait for key release
                row = P1 & 0x0F;
                if(row == 0x0E) return keypad[0][col];
                if(row == 0x0D) return keypad[1][col];
                if(row == 0x0B) return keypad[2][col];
                if(row == 0x07) return keypad[3][col];
            }
        }
    }
}
void main() {
    char entered_password[5];
    unsigned char i;
    char key;
    lcd_init(); // Initialize the LCD
    keypad_init(); // Initialize the keypad
    RELAY = 0; // Initially turn off the relay
    BUZZER = 0; // Initially turn off the buzzer
    while(1) {
        lcd_clear();
        lcd_print("Enter Password:");
        i = 0;
        while(i < 4) {
            key = keypad_getkey();
            lcd_cmd(0xC0 + i); // Move cursor to the second line
            lcd_data('*'); // Display '*' for each entered digit
            entered_password[i] = key;
            i++;
        }
        entered_password[4] = '\0'; // Null-terminate the string
        if(strcmp(entered_password, PASSWORD) == 0) {
            lcd_clear();
            lcd_print("Access Granted");
            RELAY = 1; // Unlock the door
            delay(5000); // Keep the door unlocked for 5 seconds
            RELAY = 0; // Lock the door
        } else {
            lcd_clear();
            lcd_print("Access Denied");
            BUZZER = 1; // Sound the buzzer
            delay(2000); // Keep the buzzer on for 2 seconds
            BUZZER = 0; // Turn off the buzzer
        }
        delay(1000); // Small delay before the next password entry
    }
}




Explanation


  1. Initialization:

  2. LCD Initialization: The lcd_init() function configures the LCD for display.

  3. Keypad Initialization: The keypad_init() function sets up the keypad rows as inputs and columns as outputs.

  4. Relay and Buzzer: The relay and buzzer pins are initially set low.

  5. Keypad Reading:

  6. The keypad_getkey() function scans the keypad to detect key presses. It grounds each column one at a time and reads the rows to identify the pressed key.

  7. Main Loop:

  8. Password Entry: The main loop prompts the user to enter a 4-digit password. Each digit is displayed as an asterisk on the LCD.

  9. Password Verification: The entered password is compared with the predefined password. If it matches, the relay is activated to unlock the door, and a success message is displayed. If it doesn't match, the buzzer sounds, and an error message is displayed.

  10. Delay Function:

  11. The delay function introduces a small delay between operations to ensure stability and provide adequate response times.


Conclusion


This project demonstrates the use of the 8051 microcontroller to create a door access control system. By integrating a keypad for password input, an LCD for user feedback, a relay for door control, and a buzzer for alerts, the system provides a secure and user-friendly access control solution. This project is a great way to learn about keypad interfacing, LCD display control, and using microcontrollers for security applications.


Want us to guide you through your project or make the project for you ?






Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



1 view0 comments

Related Posts

See All

Comments