0% found this document useful (0 votes)
13 views5 pages

Document

The document includes code for a fingerprint lock system using an Arduino board. It imports libraries for fingerprint scanning, keypad input, LCD display, and GSM communication. It defines pins and initializes components like the fingerprint sensor, keypad, display and GSM module. The main loop scans the keypad, checks for a fingerprint match if the # key is pressed, and sends an SMS if access is granted or denied.

Uploaded by

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

Document

The document includes code for a fingerprint lock system using an Arduino board. It imports libraries for fingerprint scanning, keypad input, LCD display, and GSM communication. It defines pins and initializes components like the fingerprint sensor, keypad, display and GSM module. The main loop scans the keypad, checks for a fingerprint match if the # key is pressed, and sends an SMS if access is granted or denied.

Uploaded by

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

#include <SoftwareSerial.

h>

#include <Adafruit_Fingerprint.h>

#include <Keypad.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h> // Include the I2C LCD library

#define FINGERPRINT_RX 2

#define FINGERPRINT_TX 3

#define GSM_RX 7

#define GSM_TX 8

#define BUZZER_PIN 5

#define TOUCH_PIN 13 // Touch Sensor connected to pin 13

SoftwareSerial fingerprintSerial(FINGERPRINT_RX, FINGERPRINT_TX);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerprintSerial);

SoftwareSerial gsmSerial(GSM_RX, GSM_TX);

const byte ROWS = 4;

const byte COLS = 4;

char keys[ROWS][COLS] = {

{'1', '2', '3', 'A'},

{'4', '5', '6', 'B'},

{'7', '8', '9', 'C'},

{'*', '0', '#', 'D'}

};

byte rowPins[ROWS] = {9, 10, 11, 12};

byte colPins[COLS] = {5, 6, 7, 8};

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

// Define the LCD address and dimensions

#define I2C_ADDR 0x27


#define LCD_WIDTH 16

#define LCD_HEIGHT 2

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_WIDTH, LCD_HEIGHT); // Create an LCD object

#define RELAY_PIN 4

void setup() {

Serial.begin(9600);

finger.begin(57600);

gsmSerial.begin(9600);

lcd.init(); // Initialize the LCD

lcd.backlight(); // Turn on the backlight

pinMode(RELAY_PIN, OUTPUT);

digitalWrite(RELAY_PIN, LOW);

pinMode(BUZZER_PIN, OUTPUT);

digitalWrite(BUZZER_PIN, LOW);

pinMode(TOUCH_PIN, INPUT_PULLUP); // Set the touch pin as input with internal pull-up resistor

// Initialize GSM

gsmSerial.println("AT");

delay(1000);

gsmSerial.println("AT+CMGF=1"); // Set SMS mode to text

delay(1000);

gsmSerial.println("AT+CNMI=2,2,0,0,0"); // New SMS notification

delay(1000);

lcd.setCursor(0, 0);

lcd.print("Fingerprint Lock");

lcd.setCursor(0, 1);
lcd.print("Enter PIN:");

void loop() {

char key = keypad.getKey();

if (key != NO_KEY) {

lcd.print(key);

// Check if touch sensor is triggered

if (digitalRead(TOUCH_PIN) == LOW) {

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Touch detected!");

delay(2000);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Fingerprint Lock");

lcd.setCursor(0, 1);

lcd.print("Enter PIN:");

if (key == '#') {

if (finger.verifyPassword()) {

int fingerprintID = finger.getImage();

if (fingerprintID == FINGERPRINT_OK) {

fingerprintID = finger.fingerID;

Serial.println("Fingerprint ID: " + String(fingerprintID));

lcd.clear();

lcd.print("Fingerprint ID:");
lcd.setCursor(0, 1);

lcd.print(fingerprintID);

delay(2000);

lcd.clear();

if (checkFingerprint(fingerprintID)) {

lcd.print("Access granted!");

unlockDoor();

sendSMS("Access granted!");

} else {

lcd.print("Access denied!");

tone(BUZZER_PIN, 1000, 1000); // Buzz for 1 second

sendSMS("Unauthorized access attempt!");

delay(5000); // Delay to prevent multiple readings

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Fingerprint Lock");

lcd.setCursor(0, 1);

lcd.print("Enter PIN:");

bool checkFingerprint(int id) {

// Implement your logic to check if the fingerprint ID is authorized

if (id == 1 || id == 2 || id == 3) {

return true;

} else {

return false;
}

void unlockDoor() {

digitalWrite(RELAY_PIN, HIGH);

delay(5000); // Keep the door unlocked for 5 seconds

digitalWrite(RELAY_PIN, LOW);

void sendSMS(String message) {

gsmSerial.println("AT+CMGS=\"+917083442058\""); // Replace with your phone number

delay(1000);

gsmSerial.println(message);

delay(1000);

gsmSerial.println((char)26); // End AT command with Ctrl+Z

delay(1000);

You might also like