Você está na página 1de 4

Chapter (7)

Home automation using microcontroller and PLC


7.1 HOME SECURITY AND FIRE FIGHTING
On this part we are going to explain step by step home security and firefighting
and control it from A to Z using microcontroller and PLC. On this application
we are going to use Arduino program for home security and TIA program for
firefighting. We are going to talk about different components that we us eon
this project.
7.1.1 Home Security
On this application we try to make the home more secure by using a lock to
open the door through a password. We enter the password through a keypad
and the microcontroller compare this password with the password in the code,
if the two passwords are similar the microcontroller gives signal to the lock to
open the door.
7.1.2 Project Components
The component of our project can be summarized as:
1- Microcontroller (Arduino)
2- Solenoid lock
3- Keypad
4- Jumpers
7.1.3 Explain the code
On this part we are going to explain the code of security system that we
programed it using Arduino.
At first we implement the library of the keypad by (#include<keypad.h>), then
we define the number of rows and columns by (const byte ROWS = 4;) and
(const byte COLS = 4;.)
After that we will define the symbol of the buttons of the keypad by (char
keymap[ROWS][COLS]) and enter the symbol of the keypad’s buttons.
We should define the pins of Arduino that we will connect the row and columns
of the keypad by (byte rowPins[ROWS] = {4, 5, 6, 7};) and (byte
colPins[COLS] = {0, 1, 2, 3};), the numbers 4,5,6,7 are the Arduino pin’s
number that we will connect the rows of keypad on it and the numbers 0,1,2,3
are the Arduino pin’s number we will connect the columns of keypad on it.
Initialize an instance of class NewKeypad through (Keypad myKeypad = Keypad (
makeKeymap (keymap), rowPins, colPins, ROWS, COLS);).

The next step we are going to enter the number we want to make it a password by
(char password[] = {'62B'};), the numbers 62B are represent the password.

In void setup we will define the input or output pins, we have a single output pin
define it by (pinMode (8,OUTPUT);) & the number 8 represent the Arduino’s pin
we are use it an output to give signal to a solenoid lock at the correct password.

We move to void loop which the code will compare the entered number by keypad
with the password by for loop.

We perform the comparison by (for(int i = 0; i < sizeof(password); i++)) & define


key (char key = myKeypad.waitForKey();) & compare the password by (if (key ==
password [i])), in case of key is equal to the password the Arduino gives signal on
pin 8 (digitalWrite (8,1);) & the lock will open, then it wait for 5 seconds (delay
(5000);), then it the Arduino remove the signal from pin 8 and the lock will close
(digitalWrite (8,0);).
7.1.4 Fire fighting
In this application we try to secure the house from fires, smoke and gas leaking
through using fire sensor to sens the fires and gas sensor to sense the gas and
smoke.

7.1.5 Explain the code

For network 1: when the fire approaches to the fire sensor it will pick up and gives
a signal to PLC.

For network 2: when the smoke or gas leaking exists in the home the gas sensor
will pick up and gives a signal to PLC.

Você também pode gostar