This document provides a detailed overview of a smart locker system based on an Arduino UNO microcontroller. The system integrates a 4x4 membrane keypad, a 16x2 I2C LCD, an R307 fingerprint sensor, a 12V solenoid lock, a 5V relay, and a buzzer. The locker can be unlocked using either a correct keypad code or a registered fingerprint.
Arduino UNO
16x2 I2C LCD
12V Solenoid Lock
4X4 Membrane Matrix Keypad
5V Relay
Fingerprint Scanner
Buzzer
12V Power Supply
/*
* Arduino based Smart Locker with Keypad, I2C LCD, R307 Fingerprint Sensor
* and 12V Solenoid Lock
*
* This code interfaces with a 4x4 membrane keypad, a 16x2 I2C LCD, an R307
* fingerprint sensor, and a 12V solenoid lock. The system allows unlocking
* the solenoid lock using either a correct keypad code or a registered
* fingerprint.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Fingerprint.h>
#include <Keypad.h>
// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Fingerprint sensor setup
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial);
// 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] = {13, 12, 11, 10}; // connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; // connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// Relay and buzzer pins
const int relayPin = 4;
const int buzzerPin = 5;
// Predefined correct code
String correctCode = "1234";
void setup() {
// Initialize serial communication
Serial.begin(9600);
finger.begin(57600);
// Initialize LCD
lcd.init();
lcd.backlight();
// Initialize relay and buzzer pins
pinMode(relayPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
digitalWrite(relayPin, LOW);
digitalWrite(buzzerPin, LOW);
// Display welcome message
lcd.setCursor(0, 0);
lcd.print("Smart Locker");
lcd.setCursor(0, 1);
lcd.print("Initializing...");
delay(2000);
lcd.clear();
// Initialize fingerprint sensor
if (finger.verifyPassword()) {
lcd.print("Sensor found");
} else {
lcd.print("Sensor not found");
while (1) { delay(1); }
}
delay(2000);
lcd.clear();
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Enter Code or");
lcd.setCursor(0, 1);
lcd.print("Scan Finger");
// Check for keypad input
String inputCode = "";
char key = keypad.getKey();
while (key != '#') {
if (key) {
inputCode += key;
lcd.setCursor(0, 1);
lcd.print(inputCode);
}
key = keypad.getKey();
}
// Check if the entered code is correct
if (inputCode == correctCode) {
unlock();
} else {
lcd.setCursor(0, 1);
lcd.print("Wrong Code");
delay(2000);
lcd.clear();
}
// Check for fingerprint
if (fingerprintMatch()) {
unlock();
}
}
bool fingerprintMatch() {
finger.getImage();
if (finger.image2Tz() != FINGERPRINT_OK) return false;
if (finger.fingerFastSearch() != FINGERPRINT_OK) return false;
return true;
}
void unlock() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Access Granted");
digitalWrite(relayPin, HIGH);
digitalWrite(b