Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO R4 WiFi Controlled Access System with I2C LCD and Keypad

Image of Arduino UNO R4 WiFi Controlled Access System with I2C LCD and Keypad

Circuit Documentation

Summary of the Circuit

This circuit is designed to interface an Arduino UNO R4 WiFi with an I2C LCD 16x2 Screen and a 4x4 Membrane Matrix Keypad. The Arduino serves as the central processing unit, controlling the LCD display and reading inputs from the keypad. The LCD is used to display messages to the user, such as prompts for password entry and access status. The keypad allows the user to input a password. The system is programmed to compare the entered password with a predefined password and display whether access is granted or denied.

Component List

Arduino UNO R4 WiFi

  • Description: A microcontroller board based on the ATmega328P with WiFi capabilities.
  • Purpose: Acts as the central controller for the circuit, processing keypad inputs and driving the LCD display.

4X4 Membrane Matrix Keypad

  • Description: A simple interface for user input, consisting of 16 buttons arranged in a 4x4 grid.
  • Purpose: Allows the user to input commands or a password.

I2C LCD 16x2 Screen

  • Description: A liquid crystal display capable of showing 16 characters per line across 2 lines, with an I2C interface for communication.
  • Purpose: Displays information to the user, such as prompts and access status.

Wiring Details

Arduino UNO R4 WiFi

  • 5V: Provides power to the I2C LCD screen.
  • GND: Common ground with the I2C LCD screen.
  • A4 (SDA): Connected to the SDA pin of the I2C LCD screen for data communication.
  • A5 (SCL): Connected to the SCL pin of the I2C LCD screen for clock signal.
  • D2-D9: Connected to the 4X4 Membrane Matrix Keypad for scanning the keypad matrix.

4X4 Membrane Matrix Keypad

  • R1-R4: Connected to digital pins D9-D6 of the Arduino UNO R4 WiFi respectively.
  • C1-C4: Connected to digital pins D5-D2 of the Arduino UNO R4 WiFi respectively.

I2C LCD 16x2 Screen

  • VCC (5V): Receives power from the 5V pin of the Arduino UNO R4 WiFi.
  • GND: Connected to the common ground of the Arduino UNO R4 WiFi.
  • SDA: Connected to the A4 pin of the Arduino UNO R4 WiFi for data communication.
  • SCL: Connected to the A5 pin of the Arduino UNO R4 WiFi for clock signal.

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

// Initialize the LCD
LiquidCrystal_I2C lcd(0x3C, 16, 2);

// Define the password
const String password = "DCBA";
String input = "";

// Keypad setup
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
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}; // Connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; // Connect to the column pinouts of the keypad

// Create the Keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Enter Password:");
}

void loop() {
  char key = keypad.getKey();
  if (key) {
    if (key == '#') {
      if (input == password) {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Access Granted");
      } else {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Incorrect Password");
      }
      delay(2000);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Enter Password:");
      input = "";
    } else if (key == '*') {
      input = "";
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Enter Password:");
    } else {
      input += key;
      lcd.setCursor(0, 1);
      lcd.print(input);
    }
  }
}

This code initializes the LCD and keypad, then enters a loop where it waits for a keypress. When a key is pressed, it is added to the input string. If the '#' key is pressed, the input string is compared to the predefined password. If the password matches, "Access Granted" is displayed; otherwise, "Incorrect Password" is shown. The '*' key clears the current input. The LCD displays prompts and feedback based on the user's input.