Home Security System using Arduino UNO in Proteus
Hello friends, I hope you all are doing well. In today's tutorial, we are going to design a Home Security System using Arduino UNO in Proteus software. It's the most commonly designed engineering project, especially in electrical, electronics and mechatronics engineering. Normally engineering students design it as a semester project during their engineering course.
So, today we will design a home security system from scratch in Proteus software. I have given the complete project below to download but I would suggest you to design it on your own so that you could understand it better. So, let's get started:
Home Security System: Project Description
- Before going into the detail, let's first download the complete Proteus Simulation with Arduino Code, by clicking the below button:
Home Security System using Arduino UNO in Proteus
Let me first give you a detailed project description i.e. what we actually want to design? We want to build a Home Security Project, which should follow these security protocols:
- Fire alarm: It should be able to detect the fire and sound an alarm to alert everyone at home.
- Smoke alarm: It should detect the gas(smoke) and turn on the alarm(if detected).
The above-mentioned security protocols will be followed 24/7. Moreover, there will be two security modes in the project, named:
- Secure Mode.
- Normal Mode.
Let's have a look at both of these modes, one by one:
1. Secure Mode
- This mode should be selected, when owners want to completely secure their home i.e. they are leaving home or while sleeping at night.
- If the Secure Mode is selected, the project should follow the following security protocols:
- Intruder Detection Alarm: It should detect the presence of any human being in the occupied premises.
- Windows Security Alarm: If someone tries to break through the windows, the project should sound an alarm.
- Door Security Alarm: If any intruder tries to break through the main door, it should again sound the alarm to alert everyone.
2. Normal Mode
- This mode should be selected, when owners are at home and just want to take the basic security measures.
- In this mode, only the Fire Alarm & Gas Alarm will work, while all other alarms will remain on standby.
Other Features
- There should be an LCD, to display values of all parameters.
- It should have a buzzer to generate an alarm, in case of emergency.
- There should a Push Button to make switches between these security modes.
Here's the final simulation, which we are going to design in today's lecture:
So, these are our requirements, which we want to achieve in this Home Security Project. Now let's have a look at the components selected for this project:
Home Security System: Components Selected
Now let's have a look at the list of components, which I have selected for this Home Security Project. I will also briefly explain the purpose of using each component.
1. Arduino UNO
- As clearly it's an Embedded Systems Project, so first of all we need to select a Microcontroller for our project.
- As I have mentioned earlier, we will use the Arduino UNO Microcontroller board for designing this project.
- Arduino UNO will act as the brain of the project and will control all sensors and modules.
2. Flame Sensor:
- A flame sensor is used to detects the presence of fire.
- The sensor basically consists of a photo-diode that detects the Infrared rays that emit from the fire. When it detects a fire, its output goes HIGH.
3. Gas Sensor (MQ-6)
- MQ-6 Gas Sensor is used to detect the concentration of gases in the environment.
- The sensor produces a potential difference proportional to the concentration of the particular gases.
- The type of gas that it detects depends upon the material used in the sensor.
- There are many gas sensors available in the market i.e. MQ-2, MQ-3, MQ-4 etc.
- These sensors are available as ready-made modules for easy interfacing with the microcontroller.
4. PIR Sensor(HC-SR501)
- HC-SR501 PIR sensor is used to detect any human being(intruder) in the Secure Mode.
- It detects the IR radiations from the human movement & generates a pulse on its output.
- The time period of the pulse could be varied by using the potentiometer on the sensor.
5. Vibration sensor(SW-420)
- The SW-420 vibration sensor is used to detect any forced entry through windows.
- In Secure Mode, if someone tries to open the window, the sensor will detect vibrations and will send a HIGH signal to the microcontroller.
6. Infrared Sensor
- An infrared sensor will be placed at the door and someone tried to enter through that door, the sensor will detect it.
- It consists of an IR transmitter and a photo-diode that are placed close to each other.
- If any object movement occurs in front of the sensor, the IR rays hit the object and return back with a particular angle called incident angle.
- This pulls the comparator output to ground or logic LOW.
7. LCD 20x4
- LCD 20x4 will be used for displaying the values of all these sensors.
- It will also display useful information i.e. which mode is selected.
8. Buzzer
- A small 5V Buzzer is used to sound the alarm.
9. LM7805
- LM7805 is a voltage regulator and is used to convert voltage from 12V to 5V.
- Power sources(i.e. battery, adapter etc.) available are normally 12V, as it has become a standard.
- Moreover, many components also operate at 12V like a buzzer or DC motor.
- While microcontrollers and sensors work on 5V, so in Embedded projects, it's quite necessary to design a voltage regulator from 12V to 5V and in some cases 3.3V.
- I normally prefer LM7805 for converting voltage from 12V to 5V.
10. Resistances(1kohm)
- We need to use a few resistances of 1kohm.
11. Small LED
- We will also use a small LED for power indication.
12. Capacitors(100uF)
- We will also use few capacitors of 100uF, as it removes any noise/ripples.
So, these are the components, we are going to use for designing Home Security System. Now let's get started with designing the Proteus Simulation:
Proteus Simulation of Home Security System
As I have told you earlier, I am going to use Proteus software for designing this project. Proteus is an excellent simulation tool, where we will not only design the circuit of this project but will also test its output. I always design my programming algorithms on simulations as working on real hardware is too time-consuming. You should remove all your programming bugs in simulation and once confirmed then design your project in real hardware. So, let's start:
Install Proteus Libraries
- Arduino boards & sensors' modules are not available in the Proteus components list.
- So, first of all, we need to install these Proteus libraries:
- Adding these libraries is quite simple, you just need to place their files in the library folder of Proteus software.
- If you got any issues, then read this guide on How to add a Library in Proteus 8.
Once you added all the libraries, now open your Proteus software.
Designing Circuit Diagram in Proteus
- Now we need to design a circuit for our project, so select these components from Proteus Components Search Box.
- First of all, let's design the voltage regulator circuit using LM7805, which will be simply converting the voltage from 12V to 5V.
- As you can see in the above figure, I have used 12V Battery, while the output of LM7805 is showing 5V and I have also placed an LED for power indication.
LCD Interfacing with Arduino:
- Next, we need to interface 20x4 LCD with Arduino UNO, so design the circuit as shown in the below figure:
Next, we need to interface five sensors with Arduino UNO, so let's add them to our Proteus simulation:
Sensors Interfacing with Arduino:
- These are simple digital & analog sensors and are all powered up at 5V.
- So, simply connect them as shown in the below figure:
- The Flame Sensor is connected to pin A0 of Arduino UNO.
- Gas Sensor is connected to pin A1 of Arduino UNO.
- PIR Sensor is connected to pin A2 of Arduino UNO.
- The Vibration Sensor is connected to pin A3 of Arduino UNO.
- The Infrared Sensor is connected to pin A4 of Arduino UNO.
For simulation, ensure all hex files are uploaded to each sensor for proper working. You can upload the source code hex file to the Arduino, by pressing Ctrl+E or by right click --> Edit properties.
Buzzer & Push Button:
- Finally, we need to add the Buzzer to sound the alarm in emergency cases, I have connected it to Pin A5 of Arduino UNO.
- I have also connected a push-button for switching the modes, connected to Pin 7 of Arduino UNO, as shown in the below figure:
- Here's the image of the complete Proteus Simulation for Home Security System:
Now let's design the Arduino programming code for Home Security Project:
Arduino Code for Home Security System
In the previous section, we have designed the Proteus simulation of the project, now let's design its Arduino Code to make it alive. Let's get started:
Initialization LCD Arduino Code
- First of all, we need to define all our variables, as you can see in the code shown in the right figure.
- I have included the Liquid Crystal Library, which is used to operate LCD.
- Next, I have defined all my sensors to the respective pins and then initialized boolean variables for storing the output of sensors.
- In the Setup loop, I have made the sensors' pins input pullup using the pinMode Arduino command.
- Finally, displayed an initialization message on the LCD screen i.e. "Home Security System using Arduino UNO By TEP".
- The message will display for around 1 second and then LCD will be cleared and the SensorDisplay function will be called, which will simply write sensors' names on the LCD screen.
- Now compile your code and add the hex file in Arduino UNO and run your PRoteus simulation.
- If everything goes fine, you will get results as shown in the below figure:
So far, we have just displayed the sensor's names, now let's read the sensors' data in the loop section:
Reading Sensors' Data
- In the loop section, first of all, we need to read the sensors' data using the digitalRead command, as shown in the code.
- After reading the sensor's data, I have called the SensorValues function, in which I have placed a check on each sensor's value and updated it on LCD.
- It's quite straightforward code, if the sensor is giving HIGH output, I am displaying Yes on LCD and if it's LOW, I am simply printing No.
- We haven't yet defined the modes, so the project will keep on reading the sensors and will display their respective value in the LCD.
- As you can see in the below figure, if the TestPin of the sensor is HIGH, its respective value on LCD is showing "Yes" and if it's LOW then "No" is written.
- Now, if you change any sensor's value, its respective value on LCD will be updated.
So, we have successfully interfaced our sensors with Arduino UNO and now it's time to add operational modes to our project.
Two Operational Modes
- As I mentioned earlier, we need to add two operational modes in our project, and the push button will be used for conversion from one mode to another.
- So, I have simply added an If loop in my code, as shown in the figure on the right side.
- In normal mode, I have simply displayed the name of the mode at the first line of LCD.
- While in secure mode, I am checking if either of the sensors goes HIGH, simply turn ON the Buzzer.
- Although, you won't be able to hear the Buzzer sound in the below figure, but you can see Buzzer's Pin is HIGH because two of the sensors are giving a response. Check the video for Buzzer working.
- We normally need to use an optocoupler or relay driver in between the buzzer and microcontroller as buzzers normally operate at 12V, but 5V buzzers are also available.
- Here's the complete Arduino Code:
/*
* All rights reserved to TEP www.TheEngineeringProjects.com
*/
#include
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define Flame A0
#define Gas A1
#define Pir A2
#define Vib A3
#define Ir A4
#define Buzzer A5
#define Switch 7
boolean Fire, Smoke, Intruder, Window, Door;
boolean Mode = false;
void setup() {
pinMode(Flame,INPUT_PULLUP);
pinMode(Gas,INPUT_PULLUP);
pinMode(Pir,INPUT_PULLUP);
pinMode(Vib,INPUT_PULLUP);
pinMode(Ir,INPUT_PULLUP);
pinMode(Switch,INPUT_PULLUP);
pinMode(Buzzer,OUTPUT);
lcd.begin(20,4);
pinMode(Buzzer, OUTPUT);
lcd.setCursor(0,1);
lcd.print("HOME SECURITY SYSTEM");
lcd.setCursor(0,2);
lcd.print(" USING ARDUINO UNO ");
lcd.setCursor(7,3);
lcd.print("By TEP ");
//delay(700);
lcd.clear();
SensorDisplay();
}
void loop()
{
Fire = digitalRead(Flame);
Smoke = digitalRead(Gas);
Intruder = digitalRead(Pir);
Window = digitalRead(Vib);
Door = digitalRead(Ir);
Mode = digitalRead(Switch);
SensorValues();
if(Mode==false) // Normal mode
{
lcd.setCursor(4,0);
lcd.print("Normal Mode");
}
else // Secure Mode
{
lcd.setCursor(4,0);
lcd.print("Secure Mode");
if((Fire == HIGH) || (Smoke == HIGH) || (Intruder == HIGH) || (Window == HIGH) || (Door == HIGH)){
digitalWrite(Buzzer, HIGH);
}else{
digitalWrite(Buzzer, LOW);
}
}
}
void SensorDisplay()
{
lcd.setCursor(0,1);
lcd.print("Fire:");
lcd.setCursor(10,1);
lcd.print("Smoke:");
lcd.setCursor(0,2);
lcd.print("Door:");
lcd.setCursor(10,2);
lcd.print("Window:");
lcd.setCursor(0,3);
lcd.print("Intruder:");
}
void SensorValues()
{
if(Fire == true){ lcd.setCursor(6,1); lcd.print("Yes");}
else{ lcd.setCursor(6,1); lcd.print("No ");}
if(Smoke == true){lcd.setCursor(17,1); lcd.print("Yes");}
else{lcd.setCursor(17,1); lcd.print("No ");}
if(Intruder == true){lcd.setCursor(11,3); lcd.print("Yes");}
else{lcd.setCursor(11,3); lcd.print("No ");}
if(Window == true){lcd.setCursor(17,2); lcd.print("Yes");}
else{lcd.setCursor(17,2); lcd.print("No ");}
if(Door == true){lcd.setCursor(6,2); lcd.print("Yes");}
else{lcd.setCursor(6,2); lcd.print("No ");}
}
Future Scope of Home Security System
- Embedded has taken over the whole world because of its user-friendliness and low cost.
- Instead of hiring security guards(which is quite expensive), now smart homes in modern societies are equipped with such home security systems.
- Modern Home Security systems are even linked with local police or security agencies for emergency help.
- Moreover, these security systems are not bound to homes only, nowadays offices, banks, shopping malls etc. are all equipped with such smart security systems.
Future Work on Home Security System
- Today, we have designed a very simple Home Security System, where we interfaced few sensors and have only placed a Buzzer.
- We will continue this project and will add smart features to it.
- Let's have a look at few features, which we can add to this project:
- We can interface the GSM module to send messages, in case of emergency.
- We can add more sensors i.e. ultrasonic sensors, different types of Gas sensors in it.
- We can also improve our code by using interrupts instead of polling.
- We can also add a camera for facial recognition.
- To improve the security, we can add a keypad and only authorized persons will have the access to enter.
- The fingerprint sensor can also be used for identification purposes.
No matter what happens, you should put safety first. Even a great security system won’t ensure full protection, which is why you might want to consider secondary measures. Hiring fire watch security will assist you on a daily basis, performing tasks that machines cannot. These veterans will protect your home or office, addressing potential hazards as they appear.
So, that was all for today. I hope you guys have enjoyed today's project. If you have any questions/queries, please ask in the comments and I will try my best to resolve them asap. Thanks for reading, take care. Bye :)
PC817 Library for Proteus
Hello friends, I hope you all are doing great. In today's tutorial, I am going to share a new
PC817 Library for Proteus. PC817 is an optocoupler / optoisolator, which is used for electrical isolation between components or modules. It's normally used after Microcontroller Pins so that back emf doesn't burn them. You should also have a look at
Introduction to PC817, I have shared its complete details there.
PC817 is used a lot in Embedded projects but is not available in Proteus, so our team has designed it for the first time. Using this Library, now you can easily simulate this optocoupler in your Proteus simulations. So, let's get started with How to download & install PC817 Library for Proteus:
PC817 Library for Proteus
- First of all, download this PC817 Library for Proteus by clicking the below button:
[dt_default_button link="https://www.theengineeringprojects.com/ArduinoProjects/PC817 Library for Proteus.zip" button_alignment="default" animation="fadeIn" size="medium" default_btn_bg_color="" bg_hover_color="" text_color="" text_hover_color="" icon="fa fa-chevron-circle-right" icon_align="left"]Download Proteus Library[/dt_default_button]
- It's a zip file, which will have a Proteus Library folder.
- Open this folder, and you will find these 2 Library files in it:
- OptocouplersTEP.IDX
- OptocouplersTEP.LIB
- Place these Library Files in the Library folder of your Proteus software.
Note:
- Now open your Proteus ISIS software or restart it if its already open.
- In the components search box, make a search for PC817.
- If everything goes fine, then you will get results as shown in below figure:
- Now place this PC817 in your workspace.
- Default optocoupler available in Proteus contains 5 Pins but this PC817 has 4 Pins, as shown in below figure:
- I have shown both optocouplers in above figure.
- Now let's design a simple circuit to have a look at How it works:
- So, connect three LogicState and one LED with PC817, as shown in below figure:
- Now run your Proteus Simulation and change the states of your buttons.
- Both On & Off states of PC817 are shown in below figure:
- So, that's How you can easily simulate PC817 in Proteus.
I hope this PC817 Library will help you in your Engineering Projects. If you got into any trouble, then ask in comments and we will help you out. Thanks for reading, take care and have fun !!! :)
2 Relay Module Interfacing with Arduino
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide a detailed discussion onÂ
2 Relay Module Interfacing with Arduino. First of all I would like to explain you that
what is relay and how to use it and then we will move forward towards 2 relay module interfacing with Arduino. I have already controlled
relay with 555 timers. 2 relay module consists of two relays. Relay is basically an electronic device or a switch which is used to open and close the circuits electronically.
A relay controls an electric circuit by opening and closing contacts in another circuit. When the relay contact is normally open (NO), there will be an open connection when the relay is not energized. When the relay contact is normally closed, there will be a closed connection even when the relay is not energized. We can use relays to control the smaller currents in different electronic circuits. 2 relay module has two relays. One relay can control two AC/DC device simultaneously. That means 2 relay module can control four AC/DC devices at a time. 2 relay module is normally used to control the DC motors in different projects e.g. robotics, automation, embedded projects etc. It can control two DC motors simultaneously. Moreover, we can also use it for different applications e.g. to control DC/AC fans, AC/DC lights, AC/DC bulbs and a lot more. The further detail about 2 relay module interfacing with Arduino will be given later in this tutorial.
2 Relay Module Interfacing with Arduino
2 Relay Module is an electronic device consists of two relays as its major components. Relay is a switch which makes or loses the connection between two different circuits. A single relay is capable of controlling two AC/DC devices simultaneously. So, 2 relay module is able to control four AC/DC devices at the same time. Mostly it is used to control the DC motors. It can also be used in different projects e.g embedded projects, robotic, automation, power etc. 2 relay module is shown in the figure given below.
1. Relay Proteus Simulation
2. 2 Relay Module  Components
- A complete list of the components used while designing 2 relay module is shown in the figure given below.
3. 2 Relay Module  Input Pins
- 2 relay module has five (5) input pins in total, each perform different action.
- Â All of its pins are provided in the table shown in the figure below.
4. 2 Relay Module  Input Pins Description
- We must know about the functions of each pin.
- 2 relay board/module input pin functions are listed in the table shown in the figure below.
- Both IN1 and IN2 comes from the micro-controller (Arduino UNO in this case).
- IN1 pin controls the 1st relay attached on 2 relay module.
- IN2 pin controls the 2nd relay attached on 2 relay module
5. 2 Relay Module  Output Pins
- 2 relay module has three (3) output pins for each relay.
- Its output pins are given in the table shown in the figure given below.
6. 2 Relay Module  Output Pins Description
- Each output pin of 2 relay module has its own functions.
- 2 relay module pin functions are listed in the table given in the figure shown below.
- NO pin is normally open pin and device attached to this pin will not work if the relay is not energized.
- COM is a common pin i.e. ground pin.
- NC is normally closed pin and device attached to this pin will start working even if the relay is not energized.
7. 2 Relay Module  Compatibility
- 2 relay module is compatible with different micro-controllers.
- Some of those micro-controllers are provided in the table shown in the figure given below.
8. 2 Relay Module  Circuit Diagram
- Circuit diagram of 2 relay module is given in the figure shown below.
9. 2 Relay Module  Interfacing with Arduino Wiring Diagrams
10. 2 Relay Module  Interfacing with Arduino Actual Diagrams
- I have provided the complete wiring diagram for 2 relay module interfacing with Arduino.
- Wiring diagram is shown in the figure given below.
11. 2 Relay Module  Interfacing with Arduino Source Code & Description
- If you are new to Arduino software then you must have a look at How to write Arduino code.
- You just need to copy and paste the source code given below in your Arduino software.
- The complete source code for 2 relay module interfacing with Arduino is given below.
int relay1 = 6;
int relay2 = 7;
void setup() {
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
}
void loop() {
digitalWrite(relay1,LOW);
delay(1000);
digitalWrite(relay1,HIGH);
delay(1000);
digitalWrite(relay2,LOW);
delay(1000);
digitalWrite(relay2,HIGH);
delay(1000);
}
- First of all I have defined relay pins.
- Then I have changed the mode of these pins to output.
- After that I have turned on and off both of the relays with the delay of 1 sec or 1000 msec.
- So, that was the brief description about the source code for 2 relay module interfacing with Arduino.
- You can download the wiring diagram and complete Arduino source code here by clicking on the button below.
12. 2 Relay Module  Features
- The most common features associated with 2 relay module are provided in the table shown in the figure given below.
13. 2 Relay Module  Application
- 2 relay module applications are given in the table shown in the figure below.
In the tutorialÂ
2 Relay Module Interfacing with Arduino, we have learnt about the components used in the design of 2 relay module. We have also learnt about the 2 relay module interfacing with Arduino. I have provided the complete Arduino source code, you can control this module using the same code. I hope you have enjoyed the tutorial. If you have any problem you can ask us in comments. Out team is 24/7 available for you. I will share different informative engineering topics in my upcoming tutorials. So, till my next tutorial, take care and bye :)
Line Following Robot using Arduino
Hello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share a very basic project named as Line Following Robot using Arduino. I have designed a three wheeler robot and have placed IR sensors beneath it to detect the black line and then I have made it move over this Black Line.
This Line Following Robot is not doing any extra feature i.e. turning or rotating back. It will just simply move in the straight line. I have also posted a short video at the botton of this tutorials which will give you better idea of how this robot moves. You should first read this tutorial and design the basic robot and once you are successful in designing the basic Line Following Robot then you should have a look at my recent Project Line following Robotic Waiter in which I have designed a Robotic waiter which follows the line and also take turns on different tables. So, let's get started with Line Following Robot using Arduino.
Line Following Robot using Arduino
- First of all I have designed the Mechanical model of the robot, which has three wheels on it.
- Its a triangular method in which the motors were attached to the front two wheels and the back wheel is a caster wheel, which is present in the middle of the robot.
- Here's the image of front wheel coupled with the DC Gear Motor:
- Now let's have a look at the rear caster wheels, shown in below image:
- Finally, I have used Acrylic as the body of the robot.
- Here's the assembled version of our Line Following Robot:
- Now that we have the mechanical design of our robot and we have assembled it completely.
- So, now comes the electronics part where we are gonna place the DC Motor Driver Circuits and will also place the IR sensors.
- I have used Arduino board for programming of this Line following Robot.
- First of all, I have designed the 2 relay baord for DC motors.
- Its circuit diagram is shown in below figure:
- We also need a voltage divider circuit because we need such a power supply from which we can get 5V, while our source battery is of 12V.
- So, in order to do that I have used 7805 Regulator IC and have designed a simple circuit as shown in below figure:
- Now placing all the components over the Line following Robot, it looked like something as shown in below figure:
- Here's the Arduino code which you need to upload in your Arduino board:
#define motorL1 8
#define motorL2 9
#define motorR1 10
#define motorR2 11
#define PwmLeft 5
#define PwmRight 6
#define SensorR 2
#define SensorL 3
#define Sensor3 A0
#define Sensor4 A1
#define TableA A4
#define TableB A2
#define TableC A5
#define TableD A3
int OriginalSpeed = 200;
int TableCount = 0;
int TableCheck = 0;
int RFCheck = 10;
void setup()
{
Serial.begin (9600);
pinMode(motorR1, OUTPUT);
pinMode(motorR2, OUTPUT);
pinMode(motorL1, OUTPUT);
pinMode(motorL2, OUTPUT);
pinMode(PwmLeft, OUTPUT);
pinMode(PwmRight, OUTPUT);
pinMode(SensorL, INPUT);
pinMode(SensorR, INPUT);
pinMode(Sensor3, INPUT);
pinMode(Sensor4, INPUT);
pinMode(TableA, INPUT);
pinMode(TableB, INPUT);
pinMode(TableC, INPUT);
pinMode(TableD, INPUT);
MotorsStop();
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
delay(2000);
// Serial.println("fghfg");
}
void loop() {
MotorsForward();
PIDController();
}
void MotorsBackward()
{
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, LOW);
digitalWrite(motorR1, HIGH);
digitalWrite(motorR2, LOW);
}
void MotorsForward()
{
digitalWrite(motorL1, LOW);
digitalWrite(motorL2, HIGH);
digitalWrite(motorR1, LOW);
digitalWrite(motorR2, HIGH);
}
void MotorsStop()
{
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, HIGH);
digitalWrite(motorR1, HIGH);
digitalWrite(motorR2, HIGH);
}
void MotorsLeft()
{
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
digitalWrite(motorR1, HIGH);
digitalWrite(motorR2, HIGH);
digitalWrite(motorL1, LOW);
digitalWrite(motorL2, HIGH);
}
void MotorsRight()
{
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
digitalWrite(motorR1, LOW);
digitalWrite(motorR2, HIGH);
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, HIGH);
}
void Motors180()
{
analogWrite(PwmLeft, 0);
analogWrite(PwmRight, 0);
digitalWrite(motorL1, HIGH);
digitalWrite(motorL2, LOW);
digitalWrite(motorR1, LOW);
digitalWrite(motorR2, HIGH);
}
void PIDController()
{
if(digitalRead(SensorL) == HIGH){analogWrite(PwmRight, 250);analogWrite(PwmLeft, 0);}
if(digitalRead(SensorR) == HIGH){analogWrite(PwmLeft, 250);analogWrite(PwmRight,0);}
if((digitalRead(SensorL) == LOW) && (digitalRead(SensorR) == LOW)){analogWrite(PwmRight, 0);analogWrite(PwmLeft, 0);}
}
- Now that's all, here's the video for Line Following Robot using Arduino which will give you better idea:
That's all for today. I hope you have enjoyed this Line Following Robot using Arduino and are gonna use it in your projects. feel free to ask in comments, if you got into any trouble. Thanks for reading. Take care !!! :)
Home Automation Project using XBee & Arduino
Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new Home Automation Project using XBee & Arduino. Home Automation Project is a most commonly designed project by the engineering students. So, that's why I have thought to create a complete Home Automation Project so that engineering students can get benefit out of it.
We all know about automation which is originated from automate or automatic. In automation the task is done automatically and you don't need to control it. In normal Home automation project, there are few sensors which are displayed wirelessly to user and there are few controls like user can ON or OFF Lights, Fans etc via remote or mobile App.
In this Project, I have used Arduino UNO board and I have designed its complete working simulation in Proteus software, so that users got sure that its working perfectly. Because we have to work a lot in designing this complete working simulation of home Automation Project that's why its not free but you can buy it for a small price of $50. In this price, you will get the compelte Arduino code along with the working Proteus Simulation. But before buying this project, must have a look at the details below so that you are sure what you are buying. So, let's get started with Home Automation Project using XBee & Arduino.
Home Automation Project using XBee & Arduino
- You can buy the complete working Proteus Simulation along with the Arduino Programming Code by clicking the below button.
- You can pay via Paypal and the download link will be instantly available to you and if you don't have the PayPal account then use our Contact Us Form and we will find some other way for you.
Buy This Project
1: Overview
- First of all, let's have an overview of this Home Automation Project.
- In this Project, I have designed two simulations, one simulation is for Remote using which we are gonna control our appliances and the second simulation is for the controlling of these appliances.
- So, when you press buttons from your remote section, a wireless command will be sent to the control board and it will turn ON or OFF the respective load.
- Moreover, there's an LCD on the Remote on which you will also check the values of the sensors.
- So, in simple words, the remote will be in your hand and using this remote you can easily turn ON or OFF your appliances and can also check the status of your different sensors wirelessly.
- Let's first have a look at the remote section:
Remote Control:
- In Remote Control Section, I have used the below main modules:
- Arduino UNO: Microcontroller Board.
- KeyPad: Commands will be sent by clicking this Keypad's buttons.
- LCD (20 x 4): For Displaying Sensor's Data & Commands.
- XBee Module: It's an RF Module used for sending wireless commands.
- Now when you click any button on your Keypad, a command is sent from Arduino to XBee Module and the XBee module then forwards that command to other XBee on the Control Unit.
- Moreover, when the Control Unit sends the Sensors' data on xbee then Arduino receives that data and then displayed that data on LCD.
- Here's the block diagram of Remote control section which will give you a better idea of its working:
- Here's the Proteus Diagram of our Remote Section:
- In the above Proteus Simulation of Remote Control, you can see that we have Arduino UNO board which is connected with LCD, KeyPad and XBee Module.
- Working of this Remote section will be discussed in the later section.
- Now let's have a look at the Control Unit Side of Home Automation Project.
Note:You must also have a look at below tutorials because I have interfaced these modules separately with Arduino as well:
Control Unit:
- In the previous section, we had an overview of the Remote section, now let's have a look at the Control Unit.
- The Control Unit is the Unit which is being controlled by the Remote Control.
- The Main components of Control Unit are:
- Arduino UNO: Microcontroller Board.
- Relays: Used to control the appliances. I have added eight relays so you can control eight appliances.
- Lamps: Indicating the Bulbs.
- DC Motors: Indicating the Fans.
- Smoke Sensor: Used to detect the Smoke.
- Flame Sensor: Used for Fire detection.
- DS18B20: Used to measure atmospheric temperature.
Note:
- On this Control unit, the Arduino UNO is getting the data from the smoke sensors and then sending this data via XBee to Remote Control.
- We have seen in the previous section that this data is then displayed over LCD.
- Moreover, when any button is pressed from the Remote Control, the command is received by this Arduino via XBee.
- On receiving this command, Arduino UNO then turns ON or OFF the respective relay which in turn ON or OFF the respective appliance.
- Here's the block diagram of this control unit:
- You can see in the above block diagram that I have connected three sensors with Arduino and Arduino is receving their values and then sending these values to the remote control via XBee.
- Moreover Relays are also connected to Arduino and then loads are further connected to these Relays.
- So, Arduino is controlling these Relays which in turn are controlling the loads.
- I have used eight relays and hence eight loads.
- The Loads I have used are all DC loads because Proteus doesn't have AC active loads in it but you can place AC loads as well.
- Here's the Proteus Simulation of Control Unit:
- You can see all the modules are present in it.
- Eight relays are present on the right side and their outputs are going into the loads.
- I have used four lamps and four DC Motors.
- Now let's have a look at their operation.
Note:You should also have a look at below tutorials in which I have interfaced these sensors separately with Arduino:
2: Operation
- I have already mentioned their operation in above section so I am not gonna discuss it in detail.
- But let's have a little talk about their operation.
- First I am gonna discuss the operation of Remote Control:
Remote Control:
- The remote Control has an XBee module which is used for wireless communication.
- The Keypad has buttons on it so now when you press button "1" on the keypad then the Signal is sent via XBee to Control Unit.
- The control unit will automatically turn on the first load when it will receive the command from button "1" of Remote Control.
- When you press "1" for the first time then the first load will turn ON but when you press button "1" again then the first load will go off.
- So, its like if you want to turn it ON then press it and if you want to turn it OFF then press again. (Quite simple :P)
- As there are eigth loads, so button "1" to "8" are working for loads "1" to "8" respectively.
- Moreover, when sensor's data come from control unit then it is updated in the LCD of Remote Control.
- Now let's have a look at the operation of Control Unit:
Control Unit:
- As the Control Unit is concerned, it keeps on waiting for the command from remote and whenever a command is received from the Remote Control, it turns ON or OFF the respective load.
- Moreover, it also sends the data of sensors continuously to the Remote Control.
- For this wireless communication, XBee is used here.
3: Working
- This is the last section of this project where will will have a look at the working of the project.
- I haven't divided this section in parts instead I have create a video which will explain the working in detail.
- Here's the First look of Remote section image while working:
- Now when the Sensor's data come from the remote Section then it will be displayed in the LCD as shown in below figure:
- You can see in the above figure that both sensors are detecting and the temperature is also displayed in the LCD.
- Now the complete working of this project is shown in the below video which will give you complete idea of this project:
Note:
- If you buy this project and you are unable to run it properly then we will provide you free service and will make it work on your laptop perfectly. :)
So, that's all for today. I hope you have liked this Home Automation Project and are gonna buy this one. But again before buying it must read this tutorial and also watch the video so that you get complete understanding of this project.
DC Motor Direction Control with Arduino in Proteus
Hello friends, hope you all are fine and having fun with life. Today, I am going to share DC Motor Direction Control with Arduino. I have designed a complete simulation in Proteus, which will help you in understanding the controlling of DC motor. I would recommend you to first read How to Control relay in Proteus ISIS which will help you in understanding the functionality of relays because in today's tutorial, I have used relays to do the DC Motor Direction Control. I have already posted a tutorial on DC Motor Drive Circuit in Proteus ISIS.
So, for DC Motor Direction Control, I have used Arduino UNO baord, so you should also download this Arduino Library for Proteus so that you can use Arduino boards in Proteus software. I have also provide the simulation and the code for DC Motor Direction Control but I would recommend you to design it on your own so that you learn from it. If you have any problem then ask in comments and I will try to resolve them. In this project, I have used Serial Terminal. So, whenever someone, sends character "C" on serial terminal then the motor will move in Clockwise Direction and when someone sends character "A" then it will move in Anti-clockwise Direction and will stop on character "S". Anyways, lets get started with DC Motor Direction Control with Arduino in Proteus ISIS.
DC Motor Direction Control with Arduino in Proteus ISIS
- You can download the Proteus simulation for DC Motor Direction Control by clicking the below button:
Download Proteus Simulation for DC Motor
- So, now let's move on with designing it, first of all get the below components from Proteus and place them in your workspace:
- Now, design a circuit in Proteus software, as shown in below figure:
- You can see in the above figure that I have used two relays which I have used for DC Motor Direction Control.
- Moreover, there's a Virtual Terminal through which I am sending the commands.
- I have used Arduino UNO board for DC Motor Direction Control through Virtual Terminal. You should download the Arduino Library for Proteus so that you can use it in Proteus.
- Now upload the below code in your Arduino software and get the hex file. You should read how to get the Hex file from Arduino.
int Motor1 = 2;
int Motor2 = 3;
void setup() {
pinMode(Motor1, OUTPUT);
pinMode(Motor2, OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available())
{
char data = Serial.read();
Serial.println(data);
if(data == 'C'){MotorClockwise();}
if(data == 'A'){MotorAntiClockwise();}
if(data == 'S'){MotorStop();}
}
}
void MotorAntiClockwise()
{
digitalWrite(Motor1, HIGH);
digitalWrite(Motor2, LOW);
}
void MotorClockwise()
{
digitalWrite(Motor1, LOW);
digitalWrite(Motor2, HIGH);
}
void MotorStop()
{
digitalWrite(Motor1, HIGH);
digitalWrite(Motor2, HIGH);
}
- In the above code, I have designed three functions which I am calling on Serial receive.
- The code is quite self explanatory but if you got problem then ask in comments and I will resolve them.
- Once everything's done then run your simulation and if you have done fine then it will start working as shown in below figure:
- Obviously, you can't see a moving DC motor in an image but you can get the idea from Relays position in above figure. :)
- The below video will give you the better idea of How it works.
So, that's all for today. Hopefully now you have got the idea of How to do DC Motor Direction Control with Arduino in Proteus ISIS. In the next tutorial, I am gonna add speed control of DC Motor. So, till then take care and have fun. :)
Intelligent Energy Saving System
Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a complete project with you guys. Its an Intelligent Energy Saving System which I designed around two years ago. So, today I thought to share it so that others could also get benefit. In this project, I have used Arduino UNO board for programming purposes. Its not much complicated project but is the basic for many complex projects.
Energy, is a small word, but is the problem of whole world. Particularly when we are talking about electrical energy. IF you consume more electrical energy then you will get quite huge bill at the end of the month. :P So, there's always work done on reducing the consumption of electrical energy and also we compare energy costs from different providers. As a human, suppose you turn ON your room fan, then normally you forget to turn it OFF and thus your bill keeps on increasing. So in order to avoid this, automation is the only tool which comes in handy. Like there must be such system which automatically detects whether someone is still in the room or not and if there's no one then lights got OFF automatically. In this way, you can quite easily reduce your electricity cost. This same concept is presented in this project, let's have a complete look over it. :)
Overview of Intelligent Energy Saving System
- In this project, we have designed a complete room and used two inductive loads i.e. bulbs and one fan.
- Now the purpose of this project was to save the energy so we used two IR sensors for counting.
- Now, if there's no one present in the room then the loads will automatically turn OFF and when someone will enter in the room then the loads will automatically turn ON.
- Moreover, we have also added a counter functionality in it i.e. the project will also count the number of people present in the room.
- All these parameters will also display on the LCD attached with Arduino.
Components Used
I am mentioning here the components used in designing this project. I am not giving the exact values as you will get them in the circuit diagrams. Here's the list:
- Arduino UNO
- IR Sensors
- 16 x 2 LCD
- 100W Bulbs
- 12V Fan
- 2 Relay Board
- 7805 (IC Regulator)
- LED (Indication)
- Resistance
- Capacitors
Circuit Diagrams of Intelligent Energy Saving System
Suppose you are designing this project then the first thing you are gonna need is the circuit diagrams for the project so here I am gonna show you all the circuit diagrams step by step so let's start:
1: Interfacing of Arduino with LCD
- First thing we are gonna need is the interfacing of Arduino with LCD. LCD used in this project is 16 x 2.
- I have first designed the simulation in Proteus as its always better to design the simulation before going into real hardware.
- Now upload the below code into it, just to test that whether its working fine or not:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
lcd.print("www.TheEngineer");
lcd.setCursor(0,1);
lcd.print("ingProjects.com");
}
void loop() {}
- Now run it and if everything's gone fine then you will get something as shown in below figure:
Note:
2: Circuit diagram of 2 Relay Board
- Next thing we are gonna need is the two relay board. Using these relays we are gonna turn ON or OFF our loads.
- Here's the circuit diagram for 2 relay board.
- As you can see in the above figure, I have used two relay board, where both the relays are controlled bt simple logic operators.
- Now instead of these logic operators, you need to give Arduino Pins here.
- I have made the first relay ON while the second relay is OFF.
- In the above figure, relay outputs are open so you can place anything here as its gonna act as switch. So, in our case the loads will be placed after this relay.
3: Circuit Design of Buzzer
- Next circuit design which we need to understand is the buzzer circuit design.
- Its quite simple and similar to 2 relay board. I have also published a detailed post on How to Design a Buzzer in Proteus ISIS, which will be quite helpful.
- Here' I am gonna explain it lightly, so let's have a look at the circuit diagram of buzzer:
- You can quite easily understand the above figure, where I have shown both the ON and OFF states of buzzer.
4: Circuit Diagram of IR Sensor:
- In this project, I have used two IR sensors, both are placed on the door one after another. You can read more about the designing of IR Sensor on my post Circuit Diagram of IR Sensor using 555 Timer.
- I have named them Entering IR Sensor and Leaving IR Sensor.
- The logic behind these two sensors is that, when someone enters in the room then he will first pass the Entering IR Sensor and then will hit the Leaving IR Sensor and if someone is leaving the room then he will first pass the Leaving IR Sensor and then will cut the Entering.
- So, in this way I am counting the persons if someone entering in the room I simply increment and if someone's leaving then I decrement.
- Now, if number of people in the room becomes zero then I turn OFF all the lights and the fan, and if there even one person in the room then I turn ON the lights and fan.
- Here's the circuit diagram of IR Sensor:
- IR transmitter and Receiver are not available in Proteus so that's why I have used the button so when you press the button, its like someone cut the beam of IR sensor, and you will get below result:
5: Complete Circuit Diagram of Intelligent Energy Saving System
- Now that we have designed the individual circuit diagrams, next thing we are gonna do is the assembly of complete project.
- So, here's the complete circuit diagram of this project:
- As you can see in the above figure, I have used two IR Sensors. The first IR Sensor is for entering in the room while the IR sensor is for leaving the room.
- Next is the buzzer circuit which is also quite simple and I have explain in detail above.
- LCD will display the no of people in a room and will also display either the bulb is ON or OFF, and also about Fan status.
- I haven't shown the relay circuit in above figure as it will not fit in the space and I think you guys can place it easily.
Programming Code for Intelligent Energy Saving System
- The code designed for this project is developed in Arduino software.
- Code is as follows:
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float celsius, fahrenheit;
int Sensor1 = A0;
int Sensor2 = A1;
int Bulb = A5;
int Fan = A4;
int Buzzer = A3;
int Counter = 0;
int Sen1Check = 0;
int Sen2Check = 0;
void setup(void)
{
Serial.begin(9600);
digitalWrite(Bulb, HIGH);
digitalWrite(Fan, HIGH);
digitalWrite(Buzzer, HIGH);
pinMode(Sensor1, INPUT);
pinMode(Sensor2, INPUT);
pinMode(Bulb, OUTPUT);
pinMode(Fan, OUTPUT);
pinMode(Buzzer, OUTPUT);
lcd.begin(20, 4);
lcd.setCursor(0, 1);
lcd.print("Temp = ");
lcd.setCursor(0, 0);
lcd.print("Counter = ");
lcd.setCursor(12, 0);
lcd.print("Persons");
}
void loop()
{
CheckEntry();
CheckLeaving();
lcd.setCursor(7, 1);
sensors.requestTemperatures();
lcd.println(sensors.getTempCByIndex(0));
lcd.setCursor(12, 1);
lcd.print(" degC");
lcd.setCursor(10, 0);
if(Counter >= 0){lcd.print(Counter);}
if(Counter < 0){Counter = 0;}
if(Counter > 0)
{
digitalWrite(Bulb, LOW);
digitalWrite(Fan, LOW);
digitalWrite(Buzzer, HIGH);
lcd.setCursor(0, 2);
lcd.print("Fan : ON ");
lcd.setCursor(0, 3);
lcd.print("Bulb : ON ");
}
if(Counter < 1)
{
digitalWrite(Bulb, HIGH);
digitalWrite(Fan, HIGH);
digitalWrite(Buzzer, HIGH);
lcd.setCursor(0, 2);
lcd.print("Fan : OFF");
lcd.setCursor(0, 3);
lcd.print("Bulb : OFF");
}
}
void CheckEntry()
{
if(((digitalRead(Sensor1) == LOW) || (Sen1Check == 1)) && (Sen2Check == 0))
{
while(digitalRead(Sensor1) == LOW);
Sen1Check = 1;
if(digitalRead(Sensor2) == LOW)
{
Counter++;
Sen1Check = 0;
while(digitalRead(Sensor2) == LOW);
}
}
}
void CheckLeaving()
{
if(((digitalRead(Sensor2) == LOW) || (Sen2Check == 1)) && (Sen1Check == 0))
{
while(digitalRead(Sensor2) == LOW);
Sen2Check = 1;
if(digitalRead(Sensor1) == LOW)
{
Counter = Counter - 1;
Sen2Check = 0;
while(digitalRead(Sensor1) == LOW);
}
}
}
- Coding isn't much difficult for this project, but still if you get into some trouble ask in comments and I will check it out.
- Here's the complete video for this Intelligent Energy Saving System, which will explain all about the project.
That's all for today. I hope I have helped you guys in some way. Till next tutorial, take care ALLAH HAFIZ :)
Design a Buzzer in Proteus ISIS
Hello friends, hope you all are having fun and enjoying life. Today's post is quite a simple one and is about designing of circuit diagram of buzzer in Proteus ISIS. Buzzer is quite a common electrical component which is used in almost every Embedded Systems project. For example, you have seen a simple UPS, it gives a beep each time the light goes off or it has depleted its battery. Buzzer is normally used for given some indication and normally this indication is kind of a warning.
Proteus has a builtin component for buzzer and its an animated component means it gives a sound (beep) when its turned ON. So, I am gonna use that one and will give you an actual beep on it. So, it won't be much difficult and quite a simple procedure. In this post, I am not gonna interface it with any Microcontroller i.e. Arduino or PIC Microcontroller but if you want then you can quite easily control it using any of them. You simply need to give pulse to it and you can control it. If I get time then I will post the control of buzzer with Arduino. So, let's start with it.
Design a Buzzer in Proteus ISIS
- First of all, get components from the Proteus library as shown in below figure:
- Now after selecting these components, design a circuit diagram in Proteus as shown in below figure:
- In the above circuit, I have used an optocoupler PC817 in order to control the buzzer.
- The optocoupler is controlled by a simple logic operator, now when you change the logic operator from 1 to 0 the buzzer will turn on.
Note:
- Optocoupler is working here on inverse logic i.e. when we send 1 then its OFF and when we send 0 then its ON.
- If you are designing it on hardware then you can use PC817 Optocoupler.
- So now if everything's fine then simply run the simulation and then click on the logic operator and you will get the below results:
- You can see in the above figure, there are two states.
- In the Buzzer ON state LED is OFF but the buzzer will be ON and you will hear a beep like sound, which obviously can't be heard here in the image. :)
- While in the OFF state LED is ON but the buzzer will be OFF and you wont hear anything.
That's quite a simple tutorial and quite easy to understand but still if you have any problem, then ask in comments. Till next tutorial, take care and have fun.