Professional Documents
Culture Documents
Development of Motion Detection Unit Usi
Development of Motion Detection Unit Usi
This research project is submitted in partial fulfilment of the requirements for the award of
the degree of Bachelor of Science in Information Sciences of Moi University
i
DECLARATION OF ORIGINALITY
This project, as presented in this report, is my original work and has not been presented for
any other University award. Any works of other authors used in it are well acknowledged at
the point of their use. No part of this thesis may be reproduced without the prior written
permission of the author and/or Moi University.
Signature Date
Declaration by Supervisor
This thesis has been submitted for examination with my approval as University Supervisor.
DEDICATION
I dedicate this project to my family. I thank you all for walking with me to this far. Your
innovative ideas and realistic relevant challenges you posed to me at all times made me think
far in regard to my education. Your financial and spiritual support is highly appreciated
throughout this period. May the Almighty bless you.
iii
ABSTRACT
The detection of motion has its roots in astronomy. The necessity to have devices that can
work on their own with minimal human control and at the same time can be controlled
remotely inspired the development of a simple motion detector component. This component
employs infrared technology for motion sensing. This project involves the implementation of
software and hardware. For the hardware part, PIR sensor, Piezzo buzzer and a laptop are
connected to each other by an ATMega328 on Arduino UNO microcontroller which acts as
the central processing unit of the whole component. PIR sensor aids in detecting presence of
someone, Piezzo buzzer is used as an alarm unit that beeps when someone is detected. The
laptop is used to program the Arduino UNO but when the component is working as
programmed, it is used to power the microcontroller and also as the status indicator module.
For the software part, C programming language was used to program the microcontroller
through the Arduino software. When motion is detected, the Piezzo buzzer beeps, the LED
pin on the microcontroller lights and “MOTION DETECTED” message is printed on the
laptop screen. The working of the piezzo buzzer and the LED is concurrent for five seconds
and the message is printed once during the same time interval. When no motion is detected
the devices remain mum as programmed. Communication between the Arduino UNO and
other devices is through voltage signals which are carriers of information. The motion
detector component that has been developed is very flexible and easy to use by users, who
can as well customize and improve it further to satisfy their varying needs.
Keywords
TABLE OF CONTENTS
DECLARATION OF ORIGINALITY i
DEDICATION ii
ABSTRACT iii
TABLE OF CONTENTS iv
LIST OF FIGURES IX
ACKNOWLEDGEMENT X
1.1 Background 1
1.2 Problem Statement 2
1.3 Aim of the Project 2
1.4 Objectives 2
1.5 Research Questions 2
1.6 Significance and Justification of the Study 2
1.7 The Proposed Solution 3
2.1 Introduction 4
2.2 Embedded Systems 4
2.2.1 Embedded Systems versus General Purpose Systems 4
2.2.2 Design Issues in Embedded Systems 5
2.2.3 Development Tool in Embedded Systems 6
2.2.4 Trends in Embedded Systems 6
2.2.4.1 Application Specific Integrated Circuits (ASIC) 6
2.2.4.2 Systems on a Chip (SOC) 7
2.2.5 Challenges with Embedded Systems Design 7
2.3 Motion Sensors 7
2.3.1 Types of Motion Sensors 8
2.3.1.1 Passive Infrared Type of sensors 8
2.3.1.2 Area Reflective Type of Sensors 9
2.4 Arduino UNO Microcontroller 9
2.4.1 Technical Specifications 10
2.4.2 Programming 10
2.4.3 Difference with other boards 10
2.4.4 Power 11
v
2.4.5 Memory 11
2.4.6 Input and Output 12
2.4.7 Communication 13
2.5 Embedded Development Cycle 13
REFERENCES 34
BIBLIOGRAPHY 35
APPENDICES 36
vi
GND Ground
LIST OF TABLES
LIST OF FIGURES
ACKNOWLEDGEMENT
Hereby, I render my sincere gratitude to all who contributed towards the successful
completion of this project.
First, I thank the Almighty God for his divine mercy, graces, gift of life, strength and wisdom
that enabled me come up with this project.
To my academic supervisor, thanks for believing in this project from the start and also
believing in me in pursuit for the development of the component above.
I cannot forget to thank Mr. Titus Koech, a fifth year BEng. Electronics and Communications
Engineering student for his immense support in understanding circuits and aid in acquisition
of devices used in the project.
To my classmates and friends, thank you for your expert advice and constructive criticism.
1
CHAPTER 1: INTRODUCTION
1.1 Background
The detection of motion finds its roots in astronomy, which goes back thousands of years
ago. Early farmers looked to the heavens and used the movement of stars to determine when
to plant crops and when to harvest them.
The first motion detection system; radar, was pioneered by Heinrich Hertz. Hertz studied the
properties of waves and found that waves could bounce off of objects and had different
speeds. This revelation was a breakthrough and as Furnish (2007) cites, the increased demand
for detection and monitoring during World War II generated technological advances in
motion sensing. And in 1940s, radar technology was sufficiently advanced that the military
could detect attacks in advance and guide aircraft, Huebsch (2014).
Although the development of radar systems was a great achievement, its applications were
limited to military use, then. One of the first applications of motion sensing outside the
military was developed by Samuel Bagno in the mid-1940s. Using his knowledge of radar
and newly developed electrical components, Bagno began doing research on an ultrasonic
alarm, which worked similarly to radar. His ultrasonic alarm created "a web of ultrasonic
waves inside a room" and detected the motion of a person, Cerruti (1995).
The invention of the ultrasonic alarm generated a demand for other non-military applications
of this technology, especially infrared technology. Although infrared detection had been
invented in the mid-1800s, its applications were limited to astronomy then, Cerruti (1995),
but over time, its scope of application has grew tremendously.
Passive Infrared, commonly known as PIR is the technology of motion detectors that is used
to detect people by sensing the thermal infrared radiation emitted by the human body. PIR
motion detectors always use thermal sensors, detecting the small temperature increase when
the sensor element is exposed to radiation and absorbs it.
2
Automation is a field that incorporates computer science and electronics heavily. The
growing need to have systems that can be controlled remotely and can be attached to almost
every appliance and furniture has seen the development of new age of computing referred to
as Internet of Things (I0T). People today need systems that can work independently and send
feedback (results of processing; output) to them and can as well monitor various processes in
their homes, offices etc. It is this need that inspires the development of a simple motion
detection unit that its use can be customized to domestic usage for unique needs.
Over time, there have been a growing need to have systems that can work independently and
can be controlled remotely. Internet has contributed to this because of its ever decreasing cost
on connection. Leased line connections such as fibre optic connections, as well as the ADSL
(Asymmetric Digital Subscriber Line) connections tend to replace PSTN (Public Switched
Telephone Network) and ISDN (Integrated Services Digital Network) connections for
everyday use.
3
Previous studies have shown challenges in implementing intelligent embedded systems with
human rights groups always on the watch out demanding for health implication of radiations
that such devices emit when in operation.
The motion sensor component being developed in this project will instead tap infrared
radiations instead of generating them to detect motion.
The setup shall be able to detect movement of animals and inanimate objects then react by
printing a message on a serial screen of a computer, switch on the buzzer and LED light
already grounded on the Arduino Uno microcontroller.
4
2.1 Introduction
This chapter offers a brief background into the areas that are related to the research
performed in this report as well as the areas that support the reasons for performing this
research.
The first section takes a look at embedded systems, the issues and tools involved in their
design, current trends and the challenges in embedded systems design.
The second section examines motion sensors and the Arduino UNO microcontroller.
Section third which is also the final section of this chapter discusses embedded development
cycle.
Simply put, the proposed outcome of this chapter is a clearer understanding of the important
variables of research as they relate to motion detection.
This is different from general purpose systems, such as the computer that sits on a desk in an
office. The processor running that computer is termed a “general purpose” processor because
it was “designed to perform many different tasks well,” Collins (2000) as opposed to an
embedded system that has been built to perform a few specific tasks either very well or
within very strict parameters.
5
Response time is a critical factor in many embedded systems; whether it is a specific time
that an embedded system tasks needs to be run or the time between tasks that is important.
The most difficult task for an embedded system designer to do is to quantify time deadlines,
decide whether these deadlines are firm, and recognize what the consequences are if these
deadlines are not met, Collins (2000).
Size is also an important decision in many embedded systems. Many embedded systems
designed today are bought and sold simply because they are smaller than the last
implementation of that product. A living example is mobile phones.
Another design issue concerning today’s embedded system designers is power consumption.
Many of embedded systems are usually very small that are handheld devices that are made to
be mobile hence; they must have a battery. Since the designer does not want the user to be
forced to plug in or recharge the device every five minutes, the designer must make important
choices in his design decisions and balance a feature’s merits against the power that the
feature will consume, Collins (2000).
A final consideration that embedded designers need to deal with is cost. Regardless of any
choice of the above issues made, an embedded product is not going to sell if its cost is
exorbitant. Most end users will sacrifice a small amount of performance, or a slightly less
amount of battery time, for an embedded product that is less costly than all of its competitors.
This demands that the designer must consider the cost of adding a particular modification to
the design and whether or not the end user will be willing to pay that additional cost for that
additional feature, Collins (2000).
6
However, there is hope in embedded systems development because they have garnered more
interest in the research community as well as their increased need. Microprocessor companies
are now delving into this interesting field. Intel, a leading processor manufacturer has a keen
eye in embedded systems that has seen it manufacture varied microcontrollers and sponsoring
research towards the realisation of Internet of Things (IoT).
This is a motivation to embedded designers because embedded systems tools are now
catching up with regular system design tools, and they have become more readily available
and diverse in their area of coverage, Stepner (1999).
Stepner (1999) opens further by stating that tools that were not available five to ten years ago
are now available as part of “common EDA development suites”. Also, there are tools that
are now available for the development of embedded system application software as well as
the development of real-time operating systems in normal computer programming languages
with C Language taking the lead.
Two of the trends currently hot in the world of embedded systems that are discussed here are
that of application specific integrated circuits (ASICs) and systems on a chip (SOC).
uses. Like the title suggests, this is an IC that has been designed for a specific
application”.
Examples of ICs that are not ASICs are standard computer parts such as RAM, ROM,
multiprocessors, etc. Examples of ICs that are ASICs are a chip designed for a toy
robot or a chip designed to examine sun spots from a satellite, Smith (1997).
Motion sensing systems involve processing of analog data to digital data for an efficient
relevant mechanical output. Therefore, they belong to a certain category of information
systems.
All objects on the earth emit light in accordance with their temperature and
surface characteristics. Naturally, light (infrared radiation) is also emitted from
our bodies. (This radiation is emitted from the body surface, and is centred on
a wave-length of 10μm.) When a person enters the detection area of the
sensor, the amount of infrared radiation incident on the sensor varies by the
amount corresponding to the difference in temperature between the body
surface and background. These sensors detect the human body by detecting the
change in incident infrared radiation. That is, the sensor is actuated by the
difference in
9
temperature between human body (which is a heat source) and floor, walls and
other objects forming the background. The same also applies to inanimate
objects such as rolling ball. This is because, when those objects move, friction
acts on them thus generating heat. This heat emits infrared radiation which the
passive infrared type can detect.
2.3.1.2 Area reflective type of sensors
These sensors detect the human body via the area reflection system.
The Arduino UNO is the best board to get started with electronics and coding.
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs,
a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.
It contains everything needed to support the microcontroller i.e. it can simply be connected to
a computer with a USB cable or powered with an AC-to-DC adapter or battery to get started.
As found in Arduino forum, Arduino UNO microcontroller has the following specifications:
2.4.1 Technical Specifications
The Uno has a resettable poly-fuse that protects the user’s computer's USB ports from shorts
and overcurrent.
Although most computers provide their own internal protection, the fuse provides an extra
layer of protection. If more than 500 mA is applied to the USB port, the fuse will
automatically break the connection until the short or overload is removed.
2.4.4 Power
The Uno board can be powered via the USB connection or with an external power supply.
The power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery.
The adapter can be connected by plugging a 2.1mm centre-positive plug into the board's
power jack. Leads from a battery can be inserted in the GND and Vin pin headers of the
POWER connector.
The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may become unstable. If
using more than 12V, the voltage regulator may overheat and damage the board. The
recommended range is 7 to 12 volts.
Vin: The input voltage to the Uno board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated
power source). You can supply voltage through this pin, or, if supplying
voltage via the power jack, access it through this pin.
5V: This pin outputs a regulated 5V from the regulator on the board. The
board can be supplied with power either from the DC power jack (7 - 12V),
the USB connector (5V), or the VIN pin of the board (7-12V). Supplying
voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your
board. We don't advise it.
3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
GND: Ground pins.
IOREF: This pin on the Uno board provides the voltage reference with which
the microcontroller operates. A properly configured shield can read the IOREF
pin voltage and select the appropriate power source or enable voltage
translators on the outputs to work with the 5V or 3.3V.
2.4.5 Memory
The ATmega328 has 32 KB (with 0.5 KB occupied by the boot-loader. It also has 2 KB of
SRAM and 1 KB of EEPROM.
1
Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using:
pinmode(), digitalwrite(), and digitalread() functions.
They operate at 5V. Each pin can provide or receive 20mA as recommended operating
condition and has an internal pull-up resistor (disconnected by default) of 20-50k ohm.
A maximum of 40mA is the best value that must not be exceeded on any I/O pin to avoid
permanent damage to the microcontroller.
Serial: Pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data. These pins are connected to the corresponding pins of the
ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: Pins 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value.
PWM: Pins 3, 5, 6, 9, 10, and 11. They provide 8-bit PWM output with the
analogWrite() function.
SPI: Pins 10, 11, 12 and 13. These pins support SPI communication using the
SPI library.
LED: Pin 13. There is a built-in LED driven by digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
TWI: Pins A4 or SDA pin and A5 or SCL pin. Support TWI communication
using the Wire library.
The Arduino UNO has 6 analog inputs, labelled A0 through A5, each of which provide 10
bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts,
though it is possible to change the upper end of their range using the AREF pin and the
analogReference() function.
2.4.7 Communication
Arduino UNO has a number of facilities for communicating with a computer, another Uno
board, or other microcontrollers.
The ATmega328 provides serial communication, which is available on digital pins 0 (RX)
and 1 (TX). An ATmega16U2 on the board channels this serial communication over USB
and appears as a virtual com port to software on the computer.
The 16U2 firmware uses the standard USB COM drivers thus reducing the need for an
external driver.
The Arduino Software (IDE) includes a serial monitor which allows simple textual data to be
sent to and from the board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the computer. However, this
may not happen (serial communication) for on pins 0 and 1.
Problem Specification
It is a statement of the problem that your program will solve without considering any possible
solutions. Its main objective is explaining in detail what the program will do.
Once the specification of the problem is complete, the developer must examine the system as
a whole. It is at this point that the developer considers specific needs such as those of
interrupt driven or timing-critical systems.
1
Tool/Chip Selection
At this stage, informed on the need, a chip is selected based on memory size, speed, special
feature availability. Issues such as cost and availability are also investigated at this stage.
Availability of tools impacts the decision to develop with a certain microcontroller. It is
essential to determine if the development decisions a developer makes are possible with the
device he or she is considering. For example, if one wishes to use C language, it is fruitful to
select a device that has a C language compiler. It is also useful to investigate the availability
of emulators, simulators and debuggers.
Software Plan
The first step in the software plan is to select an algorithm which solves the problem specified
in the problem specification stage. It is advisable to consider and compare in terms of code
side, speed, difficulty, and ease of maintenance different algorithms.
Once a basic algorithm is chosen the overall problem should be broken down into smaller
problems which are then solved by different devices (modular programming).
Device Plan
At this stage, the routines for hardware specific features are planned. These routines include:
1) Set up the reset vector
2) Set up the interrupt vectors
3) Watch the stack (hardware or software)
4) Interact with peripherals such as timers, serial ports, and analog-digital converters (ADC).
5) Work with I/O ports
Code/Debug
The modules from the software plan stage are coded in the project language. The coded
modules are compiled or assembled and all syntactic error are repaired.
Testing
Each module should be tested to ensure that it is functioning properly. Testing is done using
simulators and/or emulators. It is also important to test the hardware to be used. This is easily
done by writing small programs which test the devices.
1
Integrate
This is the last stage of embedded development cycle. At this stage, the modules are
combined to create a functioning program. At this point, it is important to test routines which
are designed to respond to specific conditions. These routines include interrupt service and
watchdog support routines. The entire program is thoroughly tested.
1
CHAPTER 3: METHODOLOGY
3.0 Introduction
This chapter consists of project planning, project block diagrams and project description. In
this chapter also, all the methods that were used to implement the project is described.
The next part focuses on hardware, software and the component and equipment that will be
used in this project.
And the third part of this chapter dwells on the programming that will be used for co-
ordinated functions of the piezzo buzzer, LED and the serial monitor with the Arduino Uno
(ATmega328 microcontroller).
The last part is on modelling for prototyping and test the system to get the result and fix it if it
the results not just like we want.
1
Literature Review for devices used in the project
Develop source code on Arduino for the sensor system, alarm system
Development of the
prototype
Finding information on PIR sensor, piezzo buzzer and Arduino UNO microcontroller
Modelling
tudy on hardware used (equipments and component)
System Testing
Study C language to write a program
This is an endeavour to develop a motion detector component that will be core to further
enhancements for relevance applicability by any user.
PIR Sensor, piezzo buzzer and a computer by use of connectors and a USB cable respectively
will be connected to the Arduino UNO microcontroller.
Piezzo buzzer and the serial monitor will be the output devices for the motion detector as the
Arduino Uno board becomes the central processing module. PIR sensor is the input
component. The serial monitor becomes the status indicator module.
1
Hardware implementation in this project consists of PIR Sensor, piezzo Buzzer, Arduino
UNO microcontroller and a computer. The Atmega328 acts like the interface between the
PIR sensor and the piezzo buzzer, computer and the LED on pin 13 of the Arduino UNO
microcontroller because it is the central processing unit that controls the flow of operation
between the input and output modules.
For the software implementation of this project, Arduino software version 1.5.6-r2 has been
used as programming editor to develop a command to the microcontroller to control the
piezzo buzzer, the LED on the microcontroller and the expected message on the serial
monitor. Arduino software allows a user to program the microcontroller by using the C
language.
The sensor module developed in this project is aimed at extending the ability of the overall
motion detector system by detecting abnormal activities happening within the environment of
the module.
PIR sensor has been picked to implement this project. This is because it allows one to sense
motion, by detecting whether a human has moved in or out of the sensors range. They are
small, inexpensive, low-power, easy to use and don't wear out.
This sensor has a sensitivity range of up to 20feet (6 metres) and a 110°X70° detection range
making it a wide lens detection sensor. This means it can measure 110° vertically (from top)
and 70° horizontally (from left to right). However, the PIR sensor can’t count how many
people are around it or how close they are to the sensor because the lens is often fixed to a
certain sweep.
The motion sensing system consists of all modules that have been developed; the sensor
system, alarm system and the status indicator system. The serial monitor will be used for
status reporting. The alarm module can be connected either along the board or some distance
away from the microcontroller. The alarm subsystem consists of a piezzo buzzer to make a
noise and LED to give some visual indicator to the user.
2
Figure 3.6.1 below is the flow chart of how the motion detector will work in its programming.
The program will have a continuous looping and will continue to execute according to the
flow chart. The program will initialize at first to make sure all the system ready to be
function. The first program to be executed sensor system then followed by the alarm and
status indicator module which will be executed concurrently.
START
Motion NO
Detected?
YES
STOP
The software design for the motion detector system was programed by use of Arduino 1.5.6-
r2 software.
The software was first downloaded from the Arduino website (www.arduino.cc) and was
then installed. See Figure 3.7.1 below.
Arduino UNO microcontroller was then connected to the computer via a USB cable, then
followed selection of the microcontroller from the ‘Tools Tab’ and lastly selection of COM
29 from the same tab as shown below in Figure 3.7.2, Figure 3.7.3 and Figure 3.7.4
respectively.
Figure 3.7.2 Configuration for connecting the Arduino UNO microcontroller with a
computer. (Source: Google Images)
2
Thereafter, an Arduino program was loaded on the microcontroller so as to test its functionality
as shown in Figure 3.7.5.
2
The figure above shows the source code that I developed using the Arduino software. I used
C programming language because it’s easy to understand and that it’s also easier detect a
mistake from the program. In comparison to Assembly language that requires the
programmer to know the inside structure of the microcontroller, C language offers more
specific coding and programs that run on C language are a lot faster than using assembly
language.
The advantage with Arduino software is, it can support either Assembly language or C
language thereby giving the user an opportunity to choose the language he or she wants to
use.
What followed next was loading the source code to the Arduino UNO by clicking the ‘Upload’
button on the Arduino Software as shown below.
2
When upload was successful, the LED on Pin 13 on the Arduino UNO board blinked twice.
Thereafter, I connected the PIR Sensor, piezzo buzzer to the Arduino UNO board. I powered
the Arduino UNO via the USB cable connecting the computer and the board.
Figure 3.7.7: PIR Sensor and Piezzo Buzzer connected to the Arduino UNO
2
Pin1 of the PIR Sensor is connected to the 5V DC voltage terminal of the Arduino UNO.
Pin3 is connected to the ground (GND) pin of the Arduino UNO. Pin2 connects to digital Pin
D3.
Here, Pins 1 and 3 are powered with 5V by the Arduino UNO, i.e. it is through these pins
connections that the PIR sensor gets the 5V that it needs to power on and operate.
It is through Pin2 that that the Arduino UNO receives output from the PIR sensor.
The anode terminal (Red cable) of the buzzer is connected to Pin13 of the Arduino UNO
whereas its cathode (black) is connected to the ground (GND) pin of the buzzer.
Piezzo buzzer has the capability of reading analog signals through its analog-digital convertor
(ADC).
2
4.1 Introduction
This chapter contains the results and discussion from the hardware and software part of the
project that have been implemented on the motion detector system. Figure 4.1.1 below shows
the overall system that has been integrated together.
YES
YES
End Testing
The PIR sensor was connected on the Arduino UNO microcontroller board as stated in section
3.7.1 above. Thereafter, a USB cable was used to connect the Arduino UNO microcontroller
to the computer.
A sample code to test the functionality of the PIR sensor was uploaded to the microcontroller.
Whenever motion was detected, the LED Pin on the Arduino UNO microcontroller blinked
for five seconds before going off. When no motion was detected, the LED pin did not light.
Figure 4.2.1.2: Testing the PIR Sensor. Note that the black cable of the Piezzo Buzzer isn’t
connected to the Arduino UNO
A sample code to test the functionality of the buzzer was uploaded to the microcontroller to
test its functionality in seamless concurrence with the PIR Sensor.
Again, whenever motion was detected, the piezzo buzzer beeped for five seconds before
going off. At LED Pin also lit for five seconds. When no motion was detected, it didn’t beep
and the LED Pin didn’t light.
2
To enhance the efficiency and effectiveness of the system, a status indicator component was
needed. To achieve this, a serial monitor ability from the Arduino software was employed.
The serial monitor acts as a virtual monitor to the Arduino UNO microcontroller making it
print a pre-programmed message on it.
Only the printing command was added to the existing source code. The program was later
uploaded to the Arduino UNO board.
As programmed, anytime motion was detected, the piezzo buzzer beeped for five seconds, the
LED pin on the Arduino UNO board lit for the same time and “MOTION DETECTED”
message was printed on the serial monitor once.
When no motion was detected, the piezzo buzzer didn’t beep, the LED on the Arduino UNO
board did not light and no message was printed on the serial monitor.
3
4.3 Discussion
When the PIR sensor detects an obstacle within its detection range, it picks the analog signal
then converts it to a digital signal which it then passes it to the Arduino Uno board as a
voltage signal. The received digital signal, whose status is HIGH (3volts), triggers the LED
installed on its Pin13 to light and the piezzo buzzer connected on the same pin to buzz. At the
same time, the message ‘MOTION DETECTED’ is printed on the serial monitor once.
When no motion is detected, the output from the PIR Sensor is low and gives off practically
no voltage signal. It is through Pin2 of the PIR Sensor that the Arduino receives output from
the PIR sensor in form of an electric signal.
The lines of code below controls the behaviour of the LED pin, piezzo buzzer and the serial
monitor:
void loop() {
value = digitalRead(switchPin);
if (HIGH == value) {
digitalWrite(ledPin, HIGH);
digitalWrite (buzzerPin,HIGH);
Serial.println ("MOTION DETECTED");
delay (10000);
counter++;
Serial.println(counter);
}
Serial.println (“MOTION DETECTED”);
else {
digitalWrite(ledPin, LOW);
}
3
I used C programming language because it’s easy to understand and that it’s also easier detect
a mistake from the program. In comparison to Assembly language that requires the
programmer to know the inside structure of the microcontroller, C language offers more
specific coding and programs that run on C language are a lot faster than using assembly
language.
The advantage with Arduino software is, it can support either Assembly language or C
language thereby giving the user an opportunity to choose the language he or she wants to
use.
Even though I encountered some problems in testing the system, the flow chart that I
developed for testing the system was very useful as it gave me less time to debug the system.
Also, the flow chart gave me an easier way to detect any mistake and corrected it relevantly.
3
5.1 Conclusion
The task for developing the motion sensor system using infrared technology was successful
and achieved the objective for the overall project.
From this project, I can confirm that infrared technology is key in motion sensing. The alarm
module and the status indicator component helped make the system more efficient as the
Arduino UNO microcontroller played the central processing unit (CPU) role.
The potential application of this technology in future is relevant in security, tallying and can
be enhanced further into imaging technology at a more reliable and cheaper cost.
The serial monitor in the project was as a platform to give readable notifications.
When making something new, it’s obvious that one faces several problems. The first problem
that I encountered was making the PIR Sensor work with the Arduino UNO board and also
making all the components work in a coordinated manner.
The hardest part on the project was in the programming part because I ventured into
embedded programming, a fact that made me to tirelessly read and practice this unique, fairly
hard but interesting nerve of systems development. It was a challenge making mechanical
devices work and on several occasions I had to consult Titus Koech, a friend who takes
BEng. Electrical and Communications Engineering from the School of Engineering in order
to understand circuits.
3
It was a challenge working on the project with borrowed devices from a friend who at the
same time was also working on his project. This is because of the cost, especially of the
Arduino UNO board as very few retailers of electronics are aware of it and they only make
few purchases thus making them increase its buying price.
1. Use of GSM Modem: This will increase the ability of remotely receiving a
notification and controlling a set of actions. For example, if used in a home, the user
can make the system switch on a CD player that will create an impression that
someone is inside the house.
2. Making GUI (Graphical User Interface): To make this motion sensor system more
user friendly.
3. Using a more powerful sensor: It will enhance the system by giving it the counting
ability.
4. Using spy Cameras: For taking pictures that will be sent to the user in order to know
the kind of object that has been detected within the detection range.
REFERENCES
Byte Craft Limited. First Steps in Embedded Systems, Ontario: 2002. Available
www.bytecraft.com 18th April, 2016.
Collins, M., “An Evaluation of Embedded System Behavior Using Full-System Software
Emulation” Msc. Thesis. University of Maryland, College Park, 2000.
Gwennap, L., "New Processor Paradigm: V-IRAM." Journal of Microprocessor Report, Vol.
12, No. 3 (1998) pp. 17-19.
Kozyrakis, C., et al. "Scalable Processors in the Billion-Transistor Era: IRAM." IEEE
Computer, Vol. 30, No. 9, (1997) pp. 75-78.
Stepner, D., et al. “Embedded application design using a real-time OS.” DAC 99: New
Orleans LA, 1999.
Internet Sources
Cerruti, L.,"Dante's Bones." Archimedes; The Sciences in the European Periphery During
the Enlightenment, (1995) pp. 95-178.
Motion Sensors. Illumin. Hp. 2007. Motion Sensors. Furnish, T., Available
www.illumin.usc.edu 9th Dec.2015
www.media.digikey.com/pdf/data%20sheets/panasonic%20electric%20works%20pdfs/amn
%20design%20manual.pdf
www.arduino.cc
3
BIBLIOGRAPHY
Abeni, L., and Buttazzo, G., "Integrating multimedia applications into hard real-time
systems." In Proc. IEEE Real-Time Systems Symposium (RTSS), 1998.
Adafruit Learning Systems. PIR Motion Sensor Created by Lady Ada. Available
www.learn.adafruit.com 30th March, 2016.
Kalinsky, D., "A survey of task schedulers." In Embedded Systems Conference. San Jose CA,
1999.
Lee, A., and Seshia, A., Introduction to Embedded Systems: A Cyber-Physical Systems
Approach. UC Berkley, 2011. Available www.leeseshia.org 16th March 2016.
Liu, J., Real-Time Systems. Prentice Hall: Upper Saddle River NJ, 2000.
Samingan B.L., “Radio Frequency Identification and Global System for Mobile
Communication Application for Anti- Theft Car Security System”. Bsc. Thesis. Universiti
Teknologi Malaysia, Skudai, 2014.
3
APPENDICES
void setup() { // Setup code for the system. Runs once only
pinMode(ledPin, OUTPUT); // output point of LED in this case Pin 13
pinMode(switchPin, INPUT); // Input point of PIR sensor
pinMode (buzzerPin, OUTPUT); // output point of Piezzo Buzzer
Serial.begin (9600);
}
/* This loop part will run over and over again as long as the Arduino has
power*/
/* this block of code reads the input value and assigns it to the integer
value.*/
void loop() {
value = digitalRead(switchPin);
if (HIGH == value) { // HIGH means motion detected
digitalWrite(ledPin, HIGH); // LED Lights for 5 seconds
digitalWrite (buzzerPin,HIGH); // Buzzer buzzes for 5 seconds
Serial.println ("MOTION DETECTED");
delay (10000); //Waits for 10seconds but is adjustable. Syntax
1000ms=1sec counter++;
Serial.println(counter);
}
else {
digitalWrite(ledPin, LOW); //LOW means no motion detected, LED & Buzzer off
}
}
3
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void loop() {
value = digitalRead(switchPin);
if (HIGH == value) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
pinMode (buzzerPin, OUTPUT);
}
void loop() {
value = digitalRead(switchPin);
if (HIGH == value) {
digitalWrite(ledPin, HIGH);
digitalWrite (buzzerPin,HIGH); //Buzzer buzzes for 5 seconds
}
else {
digitalWrite(ledPin, LOW);
}
}
3