Professional Documents
Culture Documents
MODULE (Output): PIR Sensor Doorbell using Proteus and Arduino IDE
1
MODULE 1:
PIR Sensor Doorbell
Objective
This module will discuss creating a PIR Sensor Doorbell with the use of an
Arduino. This module will also discuss the software: Proteus and Arduino IDE as these
are the software utilized in creating the simulation. The module will also discuss the
installation process as well as the interface of the software.
Overview
Proteus is a software that can simulate, design, and draw electronic circuits that
were created by Labcenter electronic. It is used to simulate or construct circuit designs
virtually. This means that the user can simulate the test circuits that the user would like to
test, with the vast amounts of both electrical and electronic components installed within
the software. The user can just about create different types of circuit designs and test all
of them.
Arduino IDE is an open-source program wherein the user can write their code to
be uploaded to the Arduino board. The program is just like the notepad wherein the user
can write their codes and test them later on. The codes written in the Arduino IDE are
called sketches, these sketches are written as text and can be exported as .hex wherein
these files can then be uploaded to the Arduino board. The program itself has its compiler
so that whenever the user saves the codes used, it immediately tells the user whether there
are errors within the code saved.
Key Features
Proteus has a lot of features that are very useful as engineering software for the
user. These features include vast components for circuit designs, the canvas that is user-
friendly and acts as the workspace, the interface that can easily be navigated by, and also
a PCB simulation so that the user can also try and test how to create the connections of
the circuit design. The vast components are by far the best features of the software,
wherein components like the expensive oscilloscope can easily be tested in the software.
The canvas also provides a very spacy workplace.
2
friendly and is hard to get lost in its interface as it provides a simple interface that the user
can easily follow. The software also has a variety of built-in codes where the user can test
and them and edit the codes to the user’s liking. The compiler also shows errors that are
easy for the user to correct.
Step 1:
Open any browser of choice and search for “proteus.”
3
Step 2:
Enter the searched keyword and click on the link “https://www.labcenter.com.”
Step 3:
After clicking on the link, click on the “Circuit Simulation Software” button on the
webpage.
4
Step 4:
After clicking on the button, if you have the money, you can buy the simulation so that
all its features are accessible, but if not, click on the Try For Free button.
Step 5:
After clicking the button, you can now download the demonstration version of the
software. The demonstration version does not have a time limit.
5
Step 6:
After downloading the demo version, click on the downloaded program to start installing
it right away.
Step 7:
After clicking on the installation setup, follow the instructions given by the installer.
6
Step 8:
Read the terms of agreement and click on the checkbox provided on the lower left, and
then click on next to start the installation properly.
Step 9:
Click on the typical installation type as this provides all of the basic features that the user
will need.
7
Step 10:
Wait for the installation of the program to finish.
Step 11:
After the installation, you can now run the program Proteus.
8
Step 12:
You can now open your Proteus Design Suite.
System Requirements
CPU: Any processor that has a 2 GHz speed or higher
Operating System: Windows 7
Memory: 3 GB RAM
File Size: 410 MB
Graphics Card: Any graphics card supporting OpenGL version 2.0 and/or Direct 3D
and multi-sampling (MSAA)
9
1.2 Arduino IDE Installation
Step 1:
In the search bar of your computer, type in Microsoft Store and click on the first result.
10
Step 2:
After clicking on the Microsoft Store result, type in Arduino IDE on the search bar of the
Microsoft store and click the search button.
Step 3:
After clicking on the search button, click on the first result that the store shows.
11
Step 4:
After clicking on the first result, click on the Install button and wait for the software to
finish downloading.
Step 5:
After downloading the software, click on the Launch button to open your Arduino IDE
software.
12
Step 6:
You can now open your Arduino IDE software.
System Requirements
CPU: Pentium 4
Operating System: Windows 10
Memory: 256 MB RAM
File Size: 600 MB
13
User Interface
2.1 Proteus
Step 1: Open Proteus and click New Project.
14
Step 3: Click next for the schematic design.
15
Step 5: Click next for the firmware.
Step 6: Click finish for the summary of the new project created.
16
1
2
3
7
Figure 1. Proteus New Project Interface
17
Name Function
1 Menu Bar This is where the File, Edit, View, Tool, etc. options
are located. These options contain all the
commands needed by the user.
2 Quick Access Tool Bar This is where the most commonly used commands
from the menu bar are placed. These commands
being New, Open, Save, etc. are already placed so
that the user does not always have to use the drop-
down menu bar to find these options.
3 Overview Window This is where you see the overall view of your
circuit design.
18
2.2 Arduino IDE
1
2
3
19
Name Function
1 Menu Bar This is where the File, Edit, Sketch, Tool, etc.
options are located. These options contain all the
commands needed by the user.
2 Quick Access Tool Bar This is where the most commonly used commands
from the menu bar are placed. These commands
being Verify, Upload, new, etc. are already placed
so the user has an easier time compiling the sketch.
3 Sketch Tab This is where the sketches are placed. The drop-
down arrow also provides the user with the
different commands for sketches.
4 Sketch Pad This is where the user creates the code for the
Arduino. This is the main location for which the
codes are tested.
Short Quiz #1
MULTIPLE CHOICE
1) What is NOT an example of a button that can simulate the circuit design in Proteus?
a) Run b) Replay
c) Advance d) Pause
2) This is where you see the overall view of the circuit design in Proteus.
a) Canvas b) Overall View
c) Overview Window d) Overview Project
20
Components
This section of the module will explain and discuss in detail each component
used in the project.
21
AREF
GROUND
IOREF DIGITAL PIN (SCK)
DIGITAL PIN (MISO)
RESET
DIGITAL PWM (MOSI)
3.3 V
5V DIGITAL PWM (SS)
DIGITAL PWM
GROUND DIGITAL PIN
GROUND
VIN DIGITAL PIN
DIGITAL PWM
ANALOG PIN A0 DIGITAL PWM
ANALOG PIN A1 DIGITAL PIN
ANALOG PIN A2 DIGITAL PWM
ANALOG PIN A3 DIGITAL PIN
ANALOG PIN A4 DIGITAL PIN
ANALOG PIN A5 DIGITAL PIN
22
DIGITAL PINS 13-10 (SPI) – Digital pins 13 to 10 are known as the Serial Peripheral
Interface Pins. These pins are used to maintain SPI communication which uses the SPI
library.
DIGITAL PIN 13 (SCK) – Digital pin 13, aside from being a digital pin, can be used as
a Serial Clock.
DIGITAL PIN 12 (MISO) – This digital pin can also be used as a Master In Slave Out.
DIGITAL PWM 11 (MOSI) – This digital pin can also be used as a Mater Out Slave In.
DIGITAL PWM 10 (SS) – This digital pin can also be used as a Slave Select.
DIGITAL PIN – From pins 0 – 13 these pins are all used as digital pins, meaning they
can either be digital inputs or digital outputs depending on how they are used.
DIGITAL PWM – Pins 3, 5, 6, 9, 10, and 11 are digital pins as well, yet these pins are
used to convert a digital signal into an analog signal that varies on the width of the Pulse.
DIGITAL PIN 1 (TX) – This digital pin is the transmitter pin of the Arduino that is used
for serial communication with other devices. Communication is possible as long as the
device also has the UART (Universal Asynchronous Receiver Transmitter) protocol.
DIGITAL PIN 0 (RX) – This digital pin is the receive pin of the Arduino that is also
used for serial communication with other devices.
23
Figure 4. PIR Sensor
The PIR Sensor has two methods on how to detect or input data, it is actually
split into two slots. It is made up of a pyroelectric sensor this means that any motion will
be detected at a certain range of the sensor as long as the body generates heat. The PIR
sensor senses heat through infrared radiation, hence the name Infrared Sensor. This type
of sensor is also a passive sensor, meaning it does not require any energy to detect motion,
it detects energy that the body generates. The lens is also an integral part of the sensor
because the Fresnel Lens is the cover that focuses the infrared signals into the pyroelectric
sensor.
24
Figure 5. LCD
The LCD consists of millions of pixels, in which the LCD’s quality is based on
the number of pixels present in it. A pixel itself is made up of three subpixels, which are
red, green, and blue colors. This is where the term RGB comes from, in which the pixels
change from either any of the subpixels inside of it. The LCD works by a backlight that
will hit these subpixels, which will then provide an output on the screen of the LCD. The
output shown on the screen of the LCD is dependent on the program code, it should also
be known that due to the small screen of the LCD, the characters it can show at a time are
limited to its size.
Short Quiz #2
MULTIPLE CHOICE
2) These pins are used to convert a digital signal into an analog signal that varies on the
width of the Pulse.
a) Analog pin b) Digital pin
c) Digital PWM d) UART pin
3) What is the lens called that is focusing the infrared signals into the pyroelectric
sensor?
a) Frenzel lens b) Fresnel lens
c) Frensel lens d) Fernel lens
25
Project creation
This section of the module will show the step-by-step procedure on how to
create the circuit design as well as the code for the circuit. Each step will also be given a
description and explanation.
26
Sounder 1 This will be where the
tune will come from.
27
First, we’re going to open our Proteus and create a new project (shown in Figures
4 – 4.6), after that we are going to search for the components needed for the project. To
search for our components, we are going to press the P button in proteus to search for the
specific components.
28
The picked components can now be placed inside the canvas which these
components will form the circuit of the project. After placing the components, we will
now connect the components to the Arduino board.
Figure 6.2 Picking the components and placing them on the Canvas
Now we are going to connect the components to the Arduino pins starting with
the LCD. Take note that the connections shown are not the only way to connect the pins,
the connection will always depend on the user, just remember the pins used when
coding the program.
29
The connections to the Arduino again are dependent on the user, but the
connections of the LCD are determined like that because first, the D0-D7 connections are
the data pins of the LCD. Only D4-D7 pins are going to be used because we are only
going to use the 4-bit mode of the LCD, meaning pins D0-D3 can be used in another
application if the need arises. The VSS and R/W pins of the LCD are connected, which
will later be connected to the ground, this is due to these two pins namely R/W are not
required for this program as the R/W pin writes into the LCD if it is low and reads from
the LCD if it is high which is the opposite of the code that we will be using. The two pins
RS and EN are the Register Select and Enable Pins. These two pins are connected to the
Arduino because the EN will take the data from the data pins and the RS is where the
register of the LCD will stay that will become its memory.
After connecting the LCD to the Arduino, we can now connect the sounder and
PIR sensor to the Arduino and the logic toggle to the sensor that will act as the high and
low input of the PIR sensor, which is fairly easy in comparison to the LCD. Again, the
connection to the Arduino pins will always be dependent on the user, as long as the user
remembers the pins used when coding the program later.
The reason why the output pin of the PIR sensor is connected to the Arduino is
that the input of the sensor will come from the motion of any person within its range. The
input will then be converted into output stating that there is motion in front of the sensor,
which will then act as the high input for our program later.
30
We can now connect the voltage source and ground for the LCD, PIR Sensor,
and the sounder. This is required so that the components will not only work, but the circuit
itself will be a closed circuit due to the grounds connected to the components.
In the tools section of Proteus, we will make use of the Terminals mode and the
different devices under it will appear in the Device Selector area as highlighted in Figure
6.5.
31
After setting up the circuit itself we can save the project itself first so we can
create the program code and come back to the circuit later. To save the project, first, we
click the File tab and click Save Project As, then save the project with the filename the
user has chosen to name it as. After choosing the filename, click the Save button and the
project is now saved.
For the coding of the program, we will use the software Arduino IDE. Let us
open our Arduino IDE and on the blank sketch, we can start with the coding required for
the PIR Sensor doorbell to work.
32
We can just delete the code placed in the new sketch provided by Arduino IDE.
In terms of coding the program, we have to first include the library for the LCD,
and also we are going to create a make-shift library for the tune of our melody which will
be played by the sounder.
33
In the Sketch tab, click the drop down arrow and select the New Tab option, this
is where we will define the notes for the tone that will be used later. After clicking the
New Tab option, name the new tab “pitches.h” and input the following notes into the
sketch. Take note that these are public constants and should not be edited.
These codes are public constants that should not be altered as they have a specific
definition for the codes. Each note has a specific tune that is defined in this code which
makes each of these notes unique.
34
After typing the code for the notes, we can now properly start coding out the
program, first in our code should be the libraries that we are going to use, which are the
LCD library and now the pitches.h library. After coding these libraries, we can start with
assigning the pins used. Take note that if the user did not follow the procedure of the
wiring, the user will have to determine the pins used for the code to work.
After the pin assignments, we will now create the melody and its duration that
will be played by the sounder in the simulation later.
The melody created is the combination of the following notes, in which each of
these notes has a pre-defined sound that will come from pitches.h sketch. The note
duration shows how each note will last, and the 0 added in the melody is when the melody
will pause and it will last for about a quarter of a note. As shown in Figure 7.1 the 4 and
8s are the duration of the notes in which it is explained how long 4 and 8 last in terms of
notes.
35
After the melody and note duration, we can now start with the void set up of the
code itself, firstly we will have to setup the LCD and the pin modes.
The numbers 16 and 2 are the size of the LCD used, meaning the LCD is a 16x2
display output. This means that the LCD can display 16 characters per line with 2 lines to
display. The pinMode code states that the sounder will be the output for the simulation
later.
We can now start with the void loop part of the code, this part of the code is the
main body of the code, which will determine how the simulation works and which of the
components will work at a given instruction.
This section determines how the components will work with the given set of
instructions provided by the program. Firstly we determined that the PIR sensor will be
in the digital pin 1 of the Arduino. The setCursor determines where the text will begin to
be displayed, the coordinates (0,0) means that the text that will be printed out will be
displayed starting from 0 columns and 0 rows. The LCD will then print out the statement
“Guest(s): “. The if statement then states that if the PIR sensor is at a low value of 0, the
next row of the LCD will print out the statement “Wave Here” signifying that if guests do
arrive, the LCD shows them where they should wave their hands. The digital write code
36
is used for our output, the sounder. This code states that if the PIR sensor is low, the
sounder should also be at a low value, meaning it should not play the tune. The delay part
of the code is used so that the program will not have a bouncing circuit in which the on
and off function of the program will not alternate rapidly, but instead, it will have a smooth
transition from being off going to on state.
Now that the first part of the loop statement is done, we can now proceed into
the next part, which is the else if. This part of the code will now determine how the
components work and how the program will give out the set of instructions when the PIR
sensor, has a high state.
This part of the code is where if the PIR sensor has a high state, the first row of
the LCD will still display the text “Guest(s): “, but the second row will now display the
text “Welcome!” The for statement will now play the tune created in the melody section
of the code. The first line of code next to the for statement iterates the notes of the melody
from 0 to 8. Next, the note duration code, states that each note duration is equal to 1000
milliseconds or 1 second. Each note duration is divided by the values stated in the iteration,
which is dependent on the stated duration of each note in Figure 7.1. The tone section, is
used to distinguish the notes that will be played by the sounder, hence the number 3 which
is the digital pin used for the sounder. The next line of codes is used to set a minimum
time between each note that is played, wherein the pause is defined as the note duration
multiplied by 30% of its duration. After defining the tone and the pause, we can now add
the noTone statement on pin 3, meaning that this code stops the tone from playing unless
the PIR sensor has a high state again. This is used so that the tone does not loop itself and
37
has a delay so that the melody will smoothly be produced by the sounder concerning the
LCD being cleared.
The final code of the sketch should look like this, in which the user can now save
both the sketch and the pitches.h library into the folder that the user will determine.
38
Figure 7.6 Saving the sketch
After saving the sketch, we can now export the sketch so that we can now import
it into the Arduino for the circuit to program as a PIR Sensor Doorbell.
39
At the bottom of the sketch pad, the compiler will show the user if there are any
malfunctions seen in the code, it should be noted that the user should always have 0 errors
after compiling for the program to function properly.
After exporting our sketch code, we can now go back to our Proteus simulation
and import the required codes for the components for our doorbell to work. Firstly we are
going to import the necessary .hex file for the PIR sensor which is a built-in function of
Proteus. Double click the PIR sensor and click the folder in line with the Program file
section.
40
Now we are going to locate the standard PIR sensor .hex file so that our PIR
sensor can function properly. The location of the .hex file for the PIR sensor will depend
on where the user installed the software, in my case, the location was at Local Disk
C/Program Files (x86)/Labcenter Electronics/Proteus 8 Professional/DATA/LIBRARY.
After locating the PIRSensorTEP.hex click the open button so that the .hex file will be
the program that the PIR sensor will run when the simulation starts.
It should show at the program file section of the PIR Sensor properties that it is
selected. We can now click the ok button after the file has been selected.
41
Now that we have the proper .hex file for our PIR Sensor, we are also going to
do the same for our Arduino board, wherein we are going to locate the sketch code that
we created earlier. Double click the Arduino board, and just like the PIR sensor, click the
folder in line with the Program File section and locate the sketch code created earlier.
42
After importing the proper .hex files for both the PIR sensor and the Arduino
board, we can now simulate our circuit project. We just have to click the Run button on
the lower left side of the software, and we can then see how the program code affects the
components and how our codes are shown in the components. An example of this is the
LCD in both the low and high value of the PIR Sensor and the sounder as well.
43
Now that concludes our PIR Sensor Doorbell simulation, it can be noted that the
user can edit with the simulation itself. Whether that be in the form of a different text
displayed in the LCD, another sensor used, a different output other than the sounder, or a
different circuit altogether.
Short Quiz #3
MULTIPLE CHOICE
1) What pins of the PIR Sensor are used as data pins of the sensor?
a) D0-D7 b) D1-D8
c) D0-D3 d) D4-D7
2) This is the part of the code that is the main body of the code.
a) Void setup b) #include
c) Void loop d) If Else If statement
4) This section of the Arduino IDE should have no errors for the code to work properly.
a) Sketch pad b) Compiler
c) Sketch export d) New tab
44
Answers to Short Quiz #1
1. b) Replay. This is not a button that can simulate a circuit design in Proteus.
2. c) Overview Window. This is where the overall view of the circuit design can be
seen.
3. b) Sketch. This is what’s called a code being generated by the Arduino IDE.
45
References
Henry. (2020, January 19). Introduction to Proteus. Introduction to Proteus -
The Engineering Knowledge. Retrieved from:
https://www.theengineeringknowledge.com/introduction-to-proteus/
Robu. (2020, July 14). Arduino Pin Configuration – Complete Guide 2021. Arduino Pin
Configuration: A Detailed Guide (2021) | Robu.in. Retrieved from:
https://robu.in/Arduino-pin-configuration/
46