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

DLD PBL

The document describes the design of a digital combination lock system. It includes representing the keypad buttons using binary signals, a circuit to convert button presses to binary, using a shift register for combination verification, a 4-bit comparator to check the combination, and a solenoid locking mechanism. It also provides block diagrams, truth tables, and code to simulate the system in Arduino.

Uploaded by

Batool 2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

DLD PBL

The document describes the design of a digital combination lock system. It includes representing the keypad buttons using binary signals, a circuit to convert button presses to binary, using a shift register for combination verification, a 4-bit comparator to check the combination, and a solenoid locking mechanism. It also provides block diagrams, truth tables, and code to simulate the system in Arduino.

Uploaded by

Batool 2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

INSTITUTE OF INDUSTRIAL ELECTRONICS ENGINEERING

Problem Based Learning


IE-245 Digital Logic Design
Digital Combina on Lock

4th Semester-Spring 2023 Batch 2021


Date: 18-09-2023

Problem Statement
Your task is to design and implement a digital combina on lock system for securing high-value assets in a single
room. The system should include a keypad for entering the combina on and a mechanism to open the lock
when the correct combina on is entered.
Task:

 How can you represent the binary signals generated by the keypad bu ons A, B, C, and D?
 Design a circuit that converts the bu on presses into corresponding binary signals.
 Explain the purpose of the shi register in the combina on verifica on process.
 What type of comparator would be suitable for comparing the entered combina on with the correct
combina on?
 What Mechanism you will use for locking and unlocking?
 Draw a block diagram illustra ng how the keypad input, combina on verifica on, and lock
mechanism components are connected.
 Create truth tables for the keypad input, combina on verifica on, and lock mechanism components.
 Iden fy the condi ons under which the lock mechanism will be unlocked.
 Simulate the digital combina on lock system using a digital logic simula on tool.
 Validate the func onality by entering different combina ons and observing the output.
KNOWLEDGE PROFILE ADDRESSED

S.No WK Attribute
2. K3 To design the logic of the given problem statement using basic logic gates,
comparators, shift registers etc., you need to have a solid foundation in
electrical engineering fundamentals
3. K4 Engineering knowledge related to Logic Designing is required for problem
solving
4. K5 The ability to design and implement Digital Combination Lock requires a
strong understanding of engineering design principles, including problem-
solving skills, creativity, and innovation.
Problem Statement:
Our task is to design and implement a digital combina on lock system for securing high-value assets in a
single room. The system should include a keypad for entering the combina on and a mechanism to open the
lock when the correct combina on is entered.

Solution Overview

Representing Binary Signals:


The keypad bu ons A, B, C, and D can be represented using binary signals as follows:
A: 0010
B: 0011
C: 0100
D: 0101

Circuit for Binary Signal Conversion:


To convert bu on presses into corresponding binary signals, a combina on of resistors and diodes can be used
to create a simple binary encoder circuit.

Purpose of Shift Register


The shi register plays a crucial role in the combina on verifica on process. It helps in serially loading and
comparing the entered combina on with the correct combina on.

Comparator for Comparison


A 4-bit binary comparator would be suitable for comparing the entered combina on with the correct
combina on.

Locking and Unlocking Mechanism


A solenoid-based locking mechanism can be used for securing the assets. When unlocked, the solenoid
releases the lock, allowing the door or compartment to open.

Block Diagram

LED
3x4 Keypad Arduino Mega

Buzzer
Internal Circuit
3x4 Keypad:

Arduino:

Truth Table
Keypad Input/
Button Pressed Binary Signal
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
0 1010
* 1011
# 1100
Combination Verification
Entered Combination Correct Combination Match
0010 0100 No
0101 0101 Yes
0110 0011 No
0011 0011 Yes

Lock Mechanism
System State Lock State
Locked Closed
Unlocked Open

Conditions for Unlocking


The lock mechanism will be unlocked when the entered combina on matches the correct combina on.

Code Explanation:
1. Library Inclusion:

#include <Keypad.h>
This line includes the Keypad library, which allows you to interface with a keypad easily.
2. Constants and Variables:

const int ROW_NUM = 4; // Four rows const int COLUMN_NUM = 3; // Three columns
These constants define the number of rows and columns in your keypad.

char keys[ROW_NUM][COLUMN_NUM] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} };


This array keys defines the characters associated with each bu on on the keypad.

byte pin_rows[ROW_NUM] = {9, 8, 7, 6}; byte pin_column[COLUMN_NUM] = {5, 4, 3};


These arrays specify the pin connec ons for the rows and columns of the keypad.

Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM);


This line creates a Keypad object keypad using the provided pin configura ons and key mappings.

const int LED_PIN = 13; // Pin for the LED const int BUZZER_PIN = 10; // Pin for the buzzer
These constants define the pin numbers for the LED and the buzzer.

bool isLocked = true; char enteredCode[5]; // Array to store entered code int codeIndex = 0; // Index for
the entered code
These variables are used to keep track of the lock state, store the entered code, and track the index of the
entered code.
3. Setup:

void setup() { pinMode(LED_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); Serial.begin(9600); }


In the setup func on, you set the LED and buzzer pins as outputs, and start serial communica on for
debugging purposes.
4. Main Loop:

void loop() { char key = keypad.getKey(); ... }


The main loop con nuously checks for key presses using the getKey() func on from the Keypad library.
5. Handling Key Presses:

if (key && codeIndex < 4) { ... }


This checks if a key is pressed and ensures that the codeIndex is less than 4 (since you want a 4-digit code).

enteredCode[codeIndex++] = key;

This line stores the pressed key in the enteredCode array and increments codeIndex.

Serial.print("*");
This prints an asterisk to the serial monitor to provide feedback for each key press.

if (codeIndex == 4) { ... }
When 4 digits are entered, it checks the code.
6. Checking the Code:

if (checkCode("4646", enteredCode)) { unlock(); } else { activateBuzzer(); Serial.println("\nIncorrect


password."); }
If the entered code matches the correct code ("4646"), it calls the unlock() func on. Otherwise, it ac vates the
buzzer, prints an error message, and resets codeIndex.
7. Code Comparison Func on:

bool checkCode(const char* code, const char* entered) { return strcmp(code, entered) == 0; }
This func on compares the entered code with the correct code and returns true if they match.
8. Unlock Func on:

void unlock() { digitalWrite(LED_PIN, HIGH); Serial.println("\nCorrect password Entered:"); delay(5000);


digitalWrite(LED_PIN, LOW); }
This func on turns on the LED, prints a message, waits for 5 seconds, and turns off the LED.
9. Buzzer Ac va on Func on:

void activateBuzzer() { digitalWrite(BUZZER_PIN, HIGH); delay(2000); digitalWrite(BUZZER_PIN, LOW); }


This func on turns on the buzzer, waits for 2 seconds, and turns off the buzzer.

Simulation and Validation


The digital combina on lock system can be simulated using a digital logic simula on tool. Different
combina ons can be entered to observe the output.

You might also like