0% found this document useful (0 votes)
10 views8 pages

Harti Laura

The document contains an Arduino code for a security system that uses a keypad for password input to control a lock and send SMS notifications. It includes functionalities for opening a door upon correct password entry and sending alerts for incorrect attempts. The system utilizes a GSM module for SMS communication and features an LCD for user interaction.

Uploaded by

chuaronnel1988
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)
10 views8 pages

Harti Laura

The document contains an Arduino code for a security system that uses a keypad for password input to control a lock and send SMS notifications. It includes functionalities for opening a door upon correct password entry and sending alerts for incorrect attempts. The system utilizes a GSM module for SMS communication and features an LCD for user interaction.

Uploaded by

chuaronnel1988
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/ 8

CODES

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

// Include Keypad library

#include <Keypad.h>

#include <SoftwareSerial.h>

SoftwareSerial sim(10, 11);

int _timeout;

String _buffer;

String number = "+639472028044"; //-> change with your number

// Password Length

const int Password_Length = 7;

// Character to hold password input

String Data;

// Password

String Master = "1234567";

// Pin connected to lock relay signal

int lockOutput = 12;

int buzz =13;

// Counter for character entries

byte data_count = 0;

// Character to hold key input

char customKey;

// Constants for row and column sizes

const byte ROWS = 4;


const byte COLS = 4;

// Array to represent keys on keypad

char hexaKeys[ROWS][COLS] = {

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

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

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

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

};

// Connections to Arduino

byte rowPins[ROWS] = {9, 8, 7, 6};

byte colPins[COLS] = {5, 4, 3, 2};

// Create keypad object

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

// Create LCD object : Use 0x27 If 0x3F Doesn't work

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {

// Setup LCD with backlight and initialize

lcd.init();

lcd.backlight();

// Set lockOutput as an OUTPUT pin

pinMode(lockOutput, OUTPUT);

pinMode(buzz, OUTPUT);
//delay(7000); //delay for 7 seconds to make sure the modules get the signal

Serial.begin(9600);

_buffer.reserve(50);

Serial.println("Sistem Started...");

sim.begin(9600);

delay(1000);

Serial.println("Type s to send an SMS, r to receive an SMS, and c to make a call");

void loop() {

// Initialize LCD and print

lcd.setCursor(0, 0);

lcd.print("Enter Password:");

// Look for keypress

customKey = customKeypad.getKey();

if (customKey) {

// Enter keypress into array and increment counter

Data += customKey;

lcd.setCursor(data_count, 1);

lcd.print(Data[data_count]);

data_count++;

// See if we have reached the password length

if (data_count == Password_Length) {

lcd.clear();
if (Data == Master) {

// Correct Password

lcd.print("Correct Door Open");

// Turn on relay for 5 seconds

digitalWrite(lockOutput, HIGH);

delay(5000);

digitalWrite(lockOutput, LOW);

delay(500);

digitalWrite(buzz, HIGH);

delay(500);

digitalWrite(buzz, LOW);

delay(500);

digitalWrite(buzz, HIGH);

delay(500);

digitalWrite(buzz, LOW);

delay(500);

digitalWrite(buzz, HIGH);

delay(500);

digitalWrite(buzz, LOW);

delay(500);

//Serial.println ("Sending Message");

sim.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode

delay(200);

//Serial.println ("Set SMS Number");

sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message

delay(200);

String SMS = "Your Parcel Reciever box has been open!";


sim.println(SMS);

delay(100);

sim.println((char)26);// ASCII code of CTRL+Z

delay(200);

_buffer = _readSerial();

else {

// Incorrect Password

lcd.print("Incorrect");

delay(1000);

sim.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode

delay(200);

//Serial.println ("Set SMS Number");

sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message

delay(200);

String SMS = "Warning! Somebody attemted to open your parcel reciever box!";

sim.println(SMS);

delay(100);

sim.println((char)26);// ASCII code of CTRL+Z

delay(200);

_buffer = _readSerial();

digitalWrite(buzz, HIGH);

//digitalWrite(lockOutput, LOW);

delay(5000);

digitalWrite(buzz, LOW);

delay(500);

}
// Clear data and LCD display

lcd.clear();

clearData();

void clearData() {

//Reset data_count

data_count = 0;

//Reset Data

Data ="";

String _readSerial() {

_timeout = 0;

while (!sim.available() && _timeout < 12000 )

delay(13);

_timeout++;

if (sim.available()) {

return sim.readString();

}
CIRCUIT DIAGRAM
BLOCK DIAGRAM

You might also like