Page 1
i
SMART LOCK FOR CONTROLLED MEDICINE
SITI ALIAH BINTI JAAFAR
(51116212226)
NORAIN BINTI OMAR
(51116212123)
Report Submitted to fulfils the Partial Requirements for
Diploma of Engineering Technology in Medical Electronics
Universiti Kuala Lumpur
SEPT 2014
Page 2
ii
I declare that this report entitle "Smart Lock for Controlled Medicine" is the results
of my own research excepts as citied n the references. The report has not been
accepted for any diploma and is not concurrently submitted in candidate of any
other diploma.
Signature : ..............................................................
Name : ....................................................................
Date : ......................................................................
Signature : ..............................................................
Name : ....................................................................
Date : ......................................................................
Page 3
iii
We have examined this report and verify that it meets the program and University
requirements for the Diploma of Engineering Technology in Medical Electronics.
Date: Day/Month/Year Signature : ..................................................
Supervisor's Name : ..........................................................................
Official Stamp
Date: Day/Month/Year Signature : ..................................................
Co-Supervisor's Name : ....................................................................
Official Stamp
Page 4
iv
ACKNOWLEDGEMENT
All the praise is to Allah SWT because for blessing us in this project
period, we finally finished this project for the subject that is Final Year
Project. And also all respect to our Prophet Muhammad S.A.W, his royal
family and his dear friends.
We also want to give thanks to our Supervisor, Mr. Mohammed Razif
bin Mohammed Noordin, for his guidance and help in solving the projects
dysfunction that we have made during project completion week by week.
Without his helps, it is impossible for us to complete this project.
We also want to give thanks to our family that have been very
supportive to us, give us advices and financial help for completing our
project. Last but not least, we want to thank our friends for helping us by
sharing their brilliant ideas for this project.
We hope that our effort plus sacrifices by all of involved individual
that helps us with itching process will get blessing from Allah SWT. We
hope that this assignment can be benefited for all, so that our effort is not
wasted. Finally we want to say that, all of the good things is comes from
Allah and all bad things come from ourselves.
Page 5
v
CONTENT
TITLE PAGE……………………………………………………….…………….….i
DECLARATION…………………………………………………….…….……...…ii
APPROVAL PAGE………………………………………………………….……..ii
ACKNOWLEDGEMENT………………………………………………………..….iv
LIST OF CONTENT……………………………………………………………..v-vii
LIST OF FIGURES………………………………………………………………..viii
ABSTRACT……………………………………………………………..……..….…ix
CHAPTER 1- INTRODUCTION
1.1 Introduction of chapter…………………………………………....…1
1.2 Project Background…………………………………………………..2
1.3 Objectives………………………………………………………………2
1.4 Scope of Project/Limitation………………………………………...3
1.5 Problem Statement…………………………………………………..3
1.6 Summary of Chapter………………………………………………..4
CHAPTER 2 - LITERATURE REVIEW
2.1 Introduction……………………………………………………………5
2.2 History of password access lock………………………………….5
2.3 Types of Smart Lock for Controlled Medicine…………………..6
2.3.1 Keypads……………………………………………………….6
2.3.2 Access Control……………………………………………….7
2.3.3 Biometrics…………………………………………………….7
2.3.4 RFID…………………………………………………………....7
Page 6
vi
2.4 Component Detail……………………………………………….…......8
2.4.1 Arduino Nano……………………………………………….....8-9
2.4.2 TIP 122 Transistor………………………………………....…..10
2.4.3 1KΩ Resistor…………………………………………..…...11-12
2.4.4 220 Ω Resistor……………………………………………..13-16
2.4.5 12V Relay……………………………………………….……17-19
2.4.6 12V Magnetic Lock………………………………………...20-21
2.4.7 Bi Colour LED……………………………………………...22-23
CHAPTER 3- METHODOLOGY
3.1 Introduction…………………………………………………………....24
3.2 Block Diagram………………………………………………………...24
3.2.1 Block Diagram Explanation………………………….…..…25
3.3 Methodology Flow Chart…………………………………….……...26
3.3.1 Flow Chart Explanation………………………………….…..27
3.4 Flow Chart Operation…………………………………………….….28
3.4.1 Flow Chart Explanation…………………………………..….29
3.5 Budgeting…………………………………………………………..….29
3.6 Time Planning……………………………………………………...…30
3.7 Step To Do PCB Design and Fabrication………………..…..31-32
3.8 Arduino Program using Arduino Software………………..……..33
3.9.1 Software……………………………………………...….….…33
Page 7
vii
3.9.2 Arduino Software…………………………………………33-34
3.9.3 Program that are used…………………………………………...35-37
CHAPTER 4 - RESULT AND ANALYSIS
4.1 Introduction………………………………………………………..38
4.2 Result from Software………………………………………….…38
4.3 Result from Hardware……………………………………….…..39
4.4 Analysis………………………………………………………….39-40
CHAPTER 5-CONCLUSION AND SUGGESTION
5.1 Introduction………………………………………………………41
5.2 Conclusion…………………………………………………….41-42
5.3 Project Suggestion……………………………………………..42
Page 8
viii
LIST OF FIGURE
Figure ……………………………………………………………………………..page
Figure 1………………………………………………………………………………8
Figure 2……………………………………………………………………………..10
Figure 3……………………………………………………………………………..11
Figure 4……………………………………………………………………………..13
Figure 5……………………………………………………………………………..15
Figure 6……………………………………………………………………………..17
Figure 7……………………………………………………………………………..20
Figure 8……………………………………………………………………………..22
Figure 9……………………………………………………………………………..24
Figure 10…………………………………………………………………………....26
Figure 11…………………………………………………………………………....28
Figure 12…………………………………………………………………………....31
Figure 13…………………………………………………………………………....39
Figure 14…………………………………………………………………………....40
Page 9
ix
ABSTRACT
Smart Lock for Controlled Medicine is a proper standard security
which are the medicine or drugs will be secured or in most organization that
means locked and available to only doctor or authorized healthcare
professional. The objectives of this project are to upgrade medication
storage with smart security system instead of using keys which can ease
doctor or parents to access to their necessary drugs safely and under
control while making a product that are totally kid-proof. To make this
project which is smart lock for controlled medicine, Arduino Nano was used
as a main component and also as a microcontroller. The other components
are TIP 122 transistor, 12v relay and magnetic lock and also power
supplies. This project was expected to function well and successful. With
some improvement that we put by some technology, this project has al lot
of potential to be developed in future for community benefits.
Page 10
1
CHAPTER 1- INTRODUCTION
1.1 Introduction of chapter
Securing medicine or drugs are very important especially at the hospital and at
home. For medication storage, the key elements include security, safety and
integrity. With the standard or existing medication storage, medicine or drugs are
not totally secured because of using keys to access the medication storage.
By applying some technologies, medication storage are need to be improved
because nowadays, drugs or medicine was always been misused. With just using
keys to open the medication storage, so many dangerous situation could be
happen such as loss of keys or keys have been duplicated by irresponsible
person. This could contributed to the commission of the crime.
Smart Lock for Controlled medicine is a product that are proper standard security
which are the medicine or drugs will be secured or in most organization that
means locked and available to only doctor or authorized healthcare professional.
This product is suitable for hospital or home to reduce criminal in misuse drugs
and totally kid-proof.
Smart Lock for Controlled Medicine is desirable because it can increase the
security level to secure medicine or drugs. It was programmed to open when the
correct 4 digit password and '*' was pressed. The timer will countdown for 30
seconds before it automatically locked again. To lock the door before the
countdown reaches zero, the user need to press ' * ' again. To change the entry
lock, the user need to type 4 new digit code and press '#'.
Page 11
2
1.2 Project Background
Smart Lock for Controlled Medicine was chosen as a project for this Final Year
Project are because to create a user friendly project and inexpensive medication
storage. Some surveys and comparison about current security system was done
and as a result, one system that difference from current security system that
available in market are decided to be made. Besides, keypad was used as the
input for the coding system, Arduino Nano as the microcontroller, 12v magnetic
lock as the lock for this project. Smart lock for controlled medicine will be chosen
by consumer in every house in this country because the system was affordable
and friendly user; complete package that can complete with the current system.
1.3 Objectives
The objective of this project are to make this project as a most important
ingredients in medical instrument, to upgrade medication storage with smart
security system instead of using keys, to reduce criminal among teens such as
misuse drugs or stolen at hospital, to ease doctor or parents to access to
necessary drugs or medicine safely and under control. Besides, to create a user
friendly, inexpensive security system and to increase the security level.
By using the password as a security code, the security level was increase. This
code is important to recognize the user, which have the right equity to disable the
system. These system also have timer, another unique security feature.
This Smart Lock For Controlled Medicine is very easy to access if the user still
remember the passcode. By following the method and technical knowledge, we
hope these goals can achieve to make this project success and function properly.
Page 12
3
1.4 Scope of Project/Limitation
This project that is Smart Lock For Controlled Medicine does not need complex
and not too short according to the study and it should relate to the study basic idea
and operation of digital code lock.The project identifies the suitable type of Arduino
to develop interfacing link between hardware circuit and software programming.
The lock will be opened once the correct password was entered and accepted and
the countdown timer will start and the door will be locked again when the timer
reaches zero. The project that was produced must involve the use of components
and circuit that have been studied and understood.
1.5 Problem Statement
This product that is Smart Lock For Controlled Medicine is a product that can
solved the problem in securing controlled medicine at hospital or at home. BY
designing this smart lock, the user can easily access to their necessary medicine
safely and under control instead of standard medication storage that are just using
key to secure the drug or medicine.
Other than that, misuse of drug are criminal that are need to be worried these day.
To save the nation form this criminals, this smart lock for medication storage was
designed and created to reduce the criminal. By using password to access the
medication storage, the thief does not have chances to open the medication
storage by duplicating keys or anything. This product also can train the user to not
hide their medicine in hiding place to avoid children to found that medicine
because the user may forget the hiding place. With this product, medicine can be
stored at specific place and this product was totally kid-proof.
Page 13
4
1.6 Summary of Chapter
This first chapter consist of the introduction, Project Background, Objective, Scope
of Project/Limitation and Problem Statement. Chapter 1 discussed about an
introduction of the project. The main idea is about the background, Objectives,
Scope of Project/Limitation and Problem Statement of the Project was discussed.
Page 14
5
CHAPTER 2 - LITERATURE REVIEW
2.1 Introduction
Smart Lock for Controlled Medicine secure and secure drug and medicine form
any hazard such as crime or accident. These security system are often developed
and implemented following a risk assessment, which determines what internal and
external factors pose the greatest threat and proposes means to reduce this
threat. Technologies to diminish risk is access control measures such as password
entry system to help authorized healthcare professional to access. The project
identifies the suitable type of Arduino as a microcontroller to develop interfacing
link between hardware circuit and software programming. This project do not need
complex and not too short according to the study and it should relate to the study
basic idea and operation of digital code lock.
2.2 History of password access lock
In the 1950s, electronic locks preceded the modern access key and card control
used today. These early electronic locks required keys that were not user-specific,
and thus anyone with the correct key could access locked materials personal
identification numbers (PIN) remedied this weakness in the 1960s by tying
together facility access and individual password codes. The further development of
smart cards incorporated individual access right optically or magnetic logging and
multiple access levels. These keys and individual codes were both required to gain
access to resource. Biometric access controls were developed in the mid-1970s
as a result of concerns over risks associated with PINs and coded information.
Both keys and codes could be stolen. By examining unique human characteristics,
Page 15
6
biometric access controls provided more accurate identification and weren’t as
easy to counterfeit. Computer security measures such as password and encrypted
information were also established to protect digital data.
2.3 Types of Smart Lock for Controlled Medicine
2.3.1 Keypads
A keypads system is a combination lock usually appearing as a plastic input
device with at least ten numbered keys. The correct sequence of numbers must be
selected in order to gain entry. The level of security provided is a function of the
number of combinations available: the more available, the more secure the lock.
Computer- controlled keypads consist of local and centralized devices that accept
input and coded information. Keypad system are vulnerable to brute force attacks
when all possible numerical combinations have been tried. When keypad system
are in isolated areas, unauthorized attempts at entry might remain unnoticed for
long-term probing (attempts to guess codes over a long period) might also go
unnoticed.
Such weaknesses in keypad system may be overcome by placing them in visible
location and by incorporating frequent code changes, time penalties, and error
alarms. Frequent code changes, while effective in minimizing long-term probing,
require notification to all authorized entrants. Time penalties freeze or lock
up the system when a correct code hasn’t been entered within the allotted time.
This penalty significantly increase the amount of required to break into a system
using trial-and-error code guessing. Error alarms sound when incorrect codes are
entered, drawing attention to individual trying to gain entry.
Page 16
7
2.3.2 Access Control
Access control measure ensure that only authorized personnel have access to
restricted resource and thereby reduce the likelihood of criminal infiltration and
misuse. Keypads, cards, and proximity system are the most common automatic
interfaces between the access system and personnel. Access controls are a
common feature in increasingly sophisticated security management system for
offices. Not only can they deter unauthorized persons from gaining entry, but they
may also track suspicious activities of authorized users, such as late- night visits
and other unusual patterns.
2.3.3 Biometrics
As bio-metrics become more and more prominent as a recognized means of
positive identification, their use in security systems increases. Some new
electronic locks take advantage of technologies such as fingerprint scanning,
retinal scanning, iris scanning and voice print identification to authenticate users.
2.3.4 RFID
Radio-frequency identification (RFID) is the use of an object (typically referred to
as an RFID tag) applied to or incorporated into a product, animal, or person for the
purpose of identification and tracking using radio waves. Some tags can be read
from several meters away and beyond the line of sight of the reader. This
technology is also used in modern electronic locks.
Page 17
8
2.4 Component Detail
2.4.1 Arduino Nano
Figure 1 : Arduino Nano
Arduino is a family of single-board microcontrollers, aimed toward building
interactive objects or environments in an easy way. The hardware consists of
open-source board designs based on various 8-bit Atmel AVR microcontrollers or
32-bit Atmel ARM processors. The systems provide sets of digital and analog I/O
pins that can be interfaced to various extension boards and other circuits. Some
models also feature a USB interface for loading code from personal computers.
The first Arduino was introduced in 2005. Its designers sought to provide an
inexpensive and easy way for hobbyists, students, and professionals to create
devices that interact with their environment using sensors and actuators. Common
examples for beginner hobbyists include simple robots, thermostats and motion
detectors. Arduino boards come with a simple integrated development
environment (IDE) that runs on regular personal computers and allows users to
write programs for Arduino using C or C++.
Arduino boards can be purchased assembled or as do-it-yourself kits. Hardware
design information is available for those who would like to assemble an Arduino by
Page 18
9
hand. It was estimated in mid-2011 that over 300,000 official Arduinos had been
commercially produced, and in 2013 that 700,000 official boards were in users'
hands.
An Arduino board consists of an Atmel 8-bit AVR microcontroller with
complementary components that facilitate programming and incorporation into
other circuits. An important aspect of the Arduino is its standard connectors, which
lets users connect the CPU board to a variety of interchangeable add-on modules
known as shields. Arduinos have used the mega AVR series of chips, specifically
the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560. A
handful of other processors have been used by Arduino compatibles.
2.4.2 TIP 122 Transistor
Figure 2 : TIP 122 Transistor
A transistor is a semiconductor device used to amplify and switch electronic
signals and electrical power. It is composed of semiconductor material with at least
three terminals for connection to an external circuit. A voltage or current applied to
one pair of the transistor's terminals changes the current through another pair of
terminals. Because the controlled (output) power can be higher than the controlling
(input) power, a transistor can amplify a signal. Today, some transistors are
packaged individually, but many more are found embedded in integrated circuits.
Page 19
10
The transistor is the fundamental building block of modern electronic devices, and
is ubiquitous in modern electronic systems. Following its development in 1947 by
American physicists John Bardeen, Walter Brattain, and William Shockley, the
transistor revolutionized the field of electronics, and paved the way for smaller and
cheaper radios, calculators, and computers, among other things. The transistor is
on the list of IEEE milestones in electronics, and the inventors were jointly
awarded the 1956 Nobel Prize in Physics for their achievement.
2.4.3 1KΩ Resistor
Figure 3 : 1KΩ Resistor
A resistor is a passive two-terminal electrical component that implements electrical
resistance as a circuit element. Resistors act to reduce current flow, and, at the
same time, act to lower voltage levels within circuits. In electronic circuits resistors
Page 20
11
are used to limit current flow, to adjust signal levels, bias active elements,
terminate transmission lines among other uses. High-power resistors that can
dissipate many watts of electrical power as heat may be used as part of motor
controls, in power distribution systems, or as test loads for generators. Resistors
can have fixed resistances that only change slightly with temperature, time or
operating voltage. Variable resistors can be used to adjust circuit elements (such
as a volume control or a lamp dimmer), or as sensing devices for heat, light,
humidity, force, or chemical activity.
Resistors are common elements of electrical networks and electronic circuits and
are ubiquitous in electronic equipment. Practical resistors as discrete components
can be composed of various compounds and forms. Resistors are also
implemented within integrated circuits.
The electrical function of a resistor is specified by its resistance: common
commercial resistors are manufactured over a range of more than nine orders of
magnitude. The nominal value of the resistance will fall within a manufacturing
tolerance.
Page 21
12
2.4.4 220 Ω Resistor
Figure 4 : 220 Ω Resistor
A resistor is a passive two-terminal electrical component that implements electrical
resistance as a circuit element. Resistors act to reduce current flow, and, at the
same time, act to lower voltage levels within circuits. In electronic circuits resistors
are used to limit current flow, to adjust signal levels, bias active elements,
terminate transmission lines among other uses. High-power resistors that can
dissipate many watts of electrical power as heat may be used as part of motor
controls, in power distribution systems, or as test loads for generators. Resistors
can have fixed resistances that only change slightly with temperature, time or
operating voltage. Variable resistors can be used to adjust circuit elements (such
as a volume control or a lamp dimmer), or as sensing devices for heat, light,
humidity, force, or chemical activity.
Resistors are common elements of electrical networks and electronic circuits and
are ubiquitous in electronic equipment. Practical resistors as discrete components
can be composed of various compounds and forms. Resistors are also
implemented within integrated circuits.
Page 22
13
The electrical function of a resistor is specified by its resistance: common
commercial resistors are manufactured over a range of more than nine orders of
magnitude. The nominal value of the resistance will fall within a manufacturing
tolerance.
Resistor Colour Code
A resistor colour code is a colour marking which translates into a numerical value
of the resistor. The marking on the body is in the form of bands, and follows the
IEC60062 specifications as defined in their portable document file (PDF). There
are two colour code systems currently in use, which include the four-band system,
and five-band system. This multi-page article provides calculators, tables, and
charts as a quick guide.
The five-band system provides more precision, as there are three bands dedicated
for the significant digits. The fourth band is usually the multiplier, and the fifth band
is the tolerance.
However, there are exceptions to this rule, and if the fourth band is gold or silver
indicating tolerance, then the third band is the multiplier, and the fifth band
becomes the temperature coefficient value.4 Band Chart
Page 23
14
Figure 5 : Colour code for resistor
Here is a four-band chart showing a 1 k resistor colour code as an example. As
you can see, it has brown, black, and red bands. The final gold band identifies the
tolerance ± 5%.
The four-band system is the most commonly used system because it is the easiest
to learn in schools, and is usually good enough for hobby use. There are two
bands dedicated for the significant digits. The third band is the multiplier, and the
fourth band is the tolerance.
Page 24
15
How to Read
People are often wondering how to read the colour code, and the sad fact is that it
is extremely easy. Although at first it might appear difficult, with practice you
should be able to decode in your head without using a calculator. Therefore, my
advice is not to rely on any calculators for this.
Each colour band represents a numeral, and in a four-band system, the first two
bands represent the first two significant digits of the value. The third band
represents the multiplier, or the number of zeros to append, and the fourth digit is
simply the tolerance information.
In a five-band system, the first three bands represent the significant digits of the
value, whilst the fourth band is the multiplier, and the fifth band is the tolerance.
The following sections of this page show some examples of how to read resistor
colour code. You can treat them as exercises.
Colours and numbers naturally associate and are very easy to remember,
therefore if you can remember them then try to do so without any silly poem or
rhymes.
Page 25
16
2.4.5 12V Relay
Figure 6 : 12V Relay
A relay is an electrically operated switch. Many relays use an electromagnet
to mechanically operate a switch, but other operating principles are also used,
such as solid-state relays. Relays are used where it is necessary to control a
circuit by a low-power signal (with complete electrical isolation between control
and controlled circuits), or where several circuits must be controlled by one signal.
The first relays were used in long distance telegraph circuits as amplifiers: they
repeated the signal coming in from one circuit and re-transmitted it on another
circuit. Relays were used extensively in telephone exchanges and early computers
to perform logical operations.
A type of relay that can handle the high power required to directly control an
electric motor or other loads is called a contactor. Solid-state relays control power
circuits with no moving parts, instead using a semiconductor device to perform
switching. Relays with calibrated operating characteristics and sometimes multiple
operating coils are used to protect electrical circuits from overload or faults; in
modern electric power systems these functions are performed by digital
instruments still called "protective relays".
Page 26
17
A simple electromagnetic relay consists of a coil of wire wrapped around a
soft iron core, an iron yoke which provides a low reluctance path for magnetic flux,
a movable iron armature, and one or more sets of contacts (there are two in the
relay pictured). The armature is hinged to the yoke and mechanically linked to one
or more sets of moving contacts. It is held in place by a spring so that when the
relay is de-energized there is an air gap in the magnetic circuit. In this condition,
one of the two sets of contacts in the relay pictured is closed, and the other set is
open. Other relays may have more or fewer sets of contacts depending on their
function. The relay in the picture also has a wire connecting the armature to the
yoke. This ensures continuity of the circuit between the moving contacts on the
armature, and the circuit track on the printed circuit board (PCB) via the yoke,
which is soldered to the PCB.
When an electric current is passed through the coil it generates a magnetic
field that activates the armature, and the consequent movement of the movable
contact(s) either makes or breaks (depending upon construction) a connection
with a fixed contact. If the set of contacts was closed when the relay was de-
energized, then the movement opens the contacts and breaks the connection, and
vice versa if the contacts were open. When the current to the coil is switched off,
the armature is returned by a force, approximately half as strong as the magnetic
force, to its relaxed position. Usually this force is provided by a spring, but gravity
is also used commonly in industrial motor starters. Most relays are manufactured
to operate quickly. In a low-voltage application this reduces noise; in a high
voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed
across the coil to dissipate the energy from the collapsing magnetic field at
deactivation, which would otherwise generate a voltage spike dangerous to
semiconductor circuit components. Some automotive relays include a diode inside
the relay case. Alternatively, a contact protection network consisting of a capacitor
and resistor in series (snubbed circuit) may absorb the surge. If the coil is
Page 27
18
designed to be energized with alternating current (AC), a small copper "shading
ring" can be crimped to the end of the solenoid, creating a small out-of-phase
current which increases the minimum pull on the armature during the AC cycle.
Page 28
19
2.4.6 12V Magnetic Lock
Figure 7 : 12V Magnetic Lock
An electromagnetic lock, magnetic lock, or maglock is a locking device that
consists of an electromagnet and an armature plate. There are two main types of
electric locking devices. Locking devices can be either "fail safe" or "fail secure". A
fail-secure locking device remains locked when power is lost. Fail-safe locking
devices are unlocked when de-energized. Direct pull electromagnetic locks are
inherently fail-safe. Typically the electromagnet portion of the lock is attached to
the door frame and a mating armature plate is attached to the door. The two
components are in contact when the door is closed. When the electromagnet is
energized, a current passing through the electromagnet creates a magnetic flux
that causes the armature plate to attract to the electromagnet, creating a locking
action. Because the mating area of the electromagnet and armature is relatively
Page 29
20
large, the force created by the magnetic flux is strong enough to keep the door
locked even under stress.
Typical single door electromagnetic locks are offered in both 600 lbs. and
1200 lbs. dynamic holding force capacities. A "fail safe" magnetic lock requires
power to remain locked and typically not suitable for high security applications
because it is possible to disable the lock by disrupting the power supply. Despite
this, by adding a magnetic bond sensor to the lock and by using a power supply
that includes a battery backup capability, some specialized higher security
applications can be implemented. Electromagnetic locks are well suited for use on
emergency exit doors that have fire safety applications because they have no
moving parts and are therefore less likely to fail than other types of electric locks,
such as electric strikes.
The strength of today's magnetic locks compares well with that of
conventional door locks and they cost less than conventional light bulbs to
operate. There are additional pieces of release hardware installed in a typical
electromagnetic locking system. Since electromagnetic locks do not interact with
levers or door knobs on a door, typically a separate release button that cuts the
lock power supply is mounted near the door. This button usually has a timer that,
once the button is pressed, keeps the lock unlocked for either 15 or 30 seconds in
accordance with NFPA fire codes. Additionally a second release is required by fire
code. Either a motion sensor or crash bar with internal switch is used to unlock to
door on the egress side of the door automatically.
Page 30
21
2.4.7 Bi Colour LED
Figure 8 : Bi Colour LED
Bi-color LED is two different LED emitters in one case. There are two types
of these. One type consists of two dies connected to the same two leads
antiparallel to each other. Current flow in one direction emits one color, and
current in the opposite direction emits the other color. The other type consists of
two dies with separate leads for both dies and another lead for common anode or
cathode, so that they can be controlled independently.
Light-emitting diode (LED) is a two-lead semiconductor light source. It is a
basic pn-junction diode, which emits light when activated. When a suitable voltage
is applied to the leads, electrons are able to recombine with electron holes within
the device, releasing energy in the form of photons. This effect is called
electroluminescence, and the color of the light (corresponding to the energy of the
photon) is determined by the energy band gap of the semiconductor.
An LED is often small in area (less than 1 mm2) and integrated optical
components may be used to shape its radiation pattern.
Page 31
22
Appearing as practical electronic components in 1962, the earliest LEDs
emitted low-intensity infrared light. Infrared LEDs are still frequently used as
transmitting elements in remote-control circuits, such as those in remote controls
for a wide variety of consumer electronics. The first visible-light LEDs were also of
low intensity, and limited to red. Modern LEDs are available across the visible,
ultraviolet, and infrared wavelengths, with very high brightness.
Early LEDs were often used as indicator lamps for electronic devices,
replacing small incandescent bulbs. They were soon packaged into numeric
readouts in the form of seven-segment displays, and were commonly seen in
digital clocks.
Recent developments in LEDs permit them to be used in environmental and
task lighting. LEDs have many advantages over incandescent light sources
including lower energy consumption, longer lifetime, improved physical
robustness, smaller size, and faster switching. Light-emitting diodes are now used
in applications as diverse as aviation lighting, automotive headlamps, advertising,
general lighting, traffic signals, and camera flashes. However, LEDs powerful
enough for room lighting are still relatively expensive, and require more precise
current and heat management than compact fluorescent lamp sources of
comparable output.
LEDs have allowed new text, video displays, and sensors to be developed,
while their high switching rates are also useful in advanced communications
technology.
Page 32
23
CHAPTER 3- METHODOLOGY
3.1 Introduction
This chapter will discuss the function of each circuit. In the order to
develop a project, it must be plan the strategy before start to build a project. The
Gantt chart is very importance because it will guide the progress of the whole
project. The design of home security system can be essentially divided into two
parts, first, the hardware and the second one is the software. The hardware
implementation is done by the design and research for the circuit including the
component selection. In the software part, the program codes are created base on
the usage of the microcontroller and the programming Arduino used.
3.2 Block Diagram
Figure 9 : Block Diagram
3.2.1 Block Diagram Explanation
Page 33
24
Smart Lock for Controlled Medicine is activated by two power supplies ; 5V
dc is supplied to the microcontroller that is Arduino Nano and 12V dc is supplied to
energise the magnetic lock. From the block diagram, the first step is keypad. The
user must enter the code password that is four digits. After the four digits
password was entered, the microcontroller will read the send the output to the bi-
colour LED. When the wrong password was detected, the LED will red which
means the current passes in one direction through them. When the correct
password was entered, the LED will green and send signal to relay through TIP
122 transistor. The relay will activated and cut the circuit, so that no current will
pass to the magnetic lock and the door can be opened. The timer countdown will
start and the relay is deactivated automatically and the door will be locked again
when the timer reaches zero.
Page 34
25
3.3 Methodology Flow Chart
Figure 10 : Methodology Flow Chart
Page 35
26
3.3.1 Flow Chart Explanation
First of all, after done all the researches about the the information of the
project (literature review) that includes datasheet, component details, and software
that will be used, a block diagram was designed to know and identify the input,
process and the output. For drawing a PCB layout, PCB wizard software was
chosen and Arduino software was used as a compiler to upload the coding to the
microcontroller. After constructing circuit, the circuit need to be tested to analyse
the functionality. The circuit will be compared to see the functionality, and it
repeatedly tested and reconstruct until it functions correctly. When the functionality
is correct, the next step is draw a conclusion and done.
Page 36
27
3.4 Flow Chart Operation
Figure 11 : Flow Chart Operation
Page 37
28
3.4.1 Flow Chart Explanation
Smart Lock for Controlled Medicine operate for 24 hours to secure and
protect controlled medicine or drugs. After entering the password, the LED will
green if the password is correct and will red if the password entered is wrong.
When the LED is green, the door can be opened and timer countdown will active
and the door will automatically locked again when the timer reaches zero.
3.5 Budgeting
List of Component
No. Component Name Quantity Unit / Price
(RM)
Amount
(RM)
1 Arduino Nano 1 31.00 31.00
2 Resistor 2 0.15 0.30
3 TIP 122 Transistor 1 1.00 1.00
4 Bi-color LED 1 2.50 2.50
5 12v Relay 1 5.00 5.00
6 12v Magnetic Lock 1 180.00 180.00
7 Small Cupboard 1 40.00 40.00
8 Perspex 1 20.00 20.00
9 PCB Board 1 23.00 23.00
10 Wire Jumper (single core) 1 roll 18.00 18.00
TOTAL (RM) 320.80
Table 1 : Budgeting
Page 38
29
3.6 Time Planning
Table 2 : Time Planning
Page 39
30
3.7 Step To Do PCB Design and Fabrication
Figure 12 : Step To Do PCB Design and Fabrication
Step 1: Prepare a layout of the circuit on any commonly used PCB designing
software. A layout is a design which interconnects the components according to
the schematic diagram (circuit diagram). Take a mirror image print of the layout on
the OHP sheet using a laser printer. Make sure that the design is correct with
proper placement of the components.
Page 40
31
Step 2: Cut the copper board according to the size of layout. A copper board is the
base of a PCB, it can be single layer, double layer or multiplayer board.
Single layer copper board has copper on one side of the PCB, they are used to
make single layer PCBs, it is widely used by hobbyist or in the small circuits. A
double layer copper board consists of copper on both the sides of the PCB. These
boards are generally used by the industries. A multilayer board has multiple layers
of copper; they are quite costly and mainly used for complex circuitries like mother
board of PC
Step 3: Rub the copper side of PCB using steel wool. This removes the top oxide
layer of copper as well as the photo resists layer if any.
Step 4: Place the OHP sheet (wax paper) which has the printed layout on the PCB
sheet. Make sure that the printed/mirror side should be placed on the copper side
of PCB.
Step 5: Put a white paper on the OHP sheet and start ironing. The heat applied by
the electric iron causes the ink of the traces on the OHP sheet to stick on the
copper plate exactly in the same way it is printed on the OHP sheet. This means
that the copper sheet will now have the layout of the PCB printed on it. Allow the
PCB plate to cool down and slowly remove the OHP sheet. Since it is manual
process it may happen that the layout doesn’t comes properly on PCB or some of
the tracks are broken in between. Use the permanent marker and complete the
tracks properly.
Step 6: Now the layout is printed on PCB. The area covered by ink is known as
the masked area and the unwanted copper, not covered by the ink is known as
unmasked area. Now make a solution of ferric chloride. Take a plastic box and fill
it up with some water. Dissolve 2-3 tea spoon of ferric chloride power in the water.
Dip the PCB into the Etching solution (Ferric chloride solution, Fecl3) for
approximately 30 mints. The Fecl3 reacts with the unmasked copper and removes
the unwanted copper from the PCB. This process is called as Etching. Use pliers
to take out the PCB and check if the entire unmasked area has been etched or
not. In case it is not etched leave it for some more time in the solution.
Page 41
32
Step 7: Take out the PCB wash it in cold water and remove the ink by rubbing it
with steel wool. The remaining area which has not been etched is the conductive
copper tracks which connect the components as per the circuit diagram.
Step 8: Now carefully drill the PCB using a drilling machine on the pads.
Step 9: Put the components in the correct holes and solder them
3.8 Arduino Program using Arduino Software
3.9.1 Software
The software section consist of a few parts which are compiler and
programmer. The compiler is the integrated with the program editor to compile the
written program. The programmer function to upload the program into the
microcontroller.
3.9.2 Arduino Software
There are many other microcontrollers and microcontroller platforms
available for physical computing. Parallax Basic Stamp, Netmedia's BX-24,
Phigets, MIT's Handyboard, and many others offer similar functionality. All of these
tools take the messy details of microcontroller programming and wrap it up in an
easy-to-use package. Arduino also simplifies the process of working with
microcontrollers, but it offers some advantage for teachers, students, and
interested amateurs over other systems:
Inexpensive - Arduino boards are relatively inexpensive compared to other
microcontroller platforms. The least expensive version of the Arduino module can
be assembled by hand, and even the pre-assembled Arduino modules cost less
than $50
Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and
Linux operating systems. Most microcontroller systems are limited to Windows.
Page 42
33
Simple, clear programming environment - The Arduino programming environment
is easy-to-use for beginners, yet flexible enough for advanced users to take
advantage of as well. For teachers, it's conveniently based on the Processing
programming environment, so students learning to program in that environment
will be familiar with the look and feel of Arduino
Open source and extensible software- The Arduino software is published as open
source tools, available for extension by experienced programmers. The language
can be expanded through C++ libraries, and people wanting to understand the
technical details can make the leap from Arduino to the AVR C programming
language on which it's based. Similarly, you can add AVR-C code directly into your
Arduino programs if you want to.
Open source and extensible hardware - The Arduino is based on Atmel's
ATMEGA8 and ATMEGA168 microcontrollers. The plans for the modules are
published under a Creative Commons license, so experienced circuit designers
can make their own version of the module, extending it and improving it. Even
relatively inexperienced users can build the breadboard version of the module in
order to understand how it works and save money.
Page 43
34
3.9.3 Program that are used.
Step I - Initialize the EEPROM
#include <EEPROM.h>
/* initialise EEPROM with default code */
void setup()
EEPROM.write(0,'1');
EEPROM.write(1,'2');
EEPROM.write(2,'3');
EEPROM.write(3,'4');
void loop()
This simple program should be uploaded to the Arduino before going any further. All it does is use the EEPROM library to initialise the first four EEPROM locations with the ASCII characters for 1, 2, 3 and 4. Note, ASCII is required as the keypad library function is designed to convert keypad presses into characters (more on this later).
Step 2: The actual code
Now the EEPROM initialised and the real code was put in place.
#include <Keypad.h>
#include <EEPROM.h>
// standard keypad set-up code taken from Alexander Brevig
// keypad example "HelloKeypad" in IDE File->Examples->Keypad
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] =
'1','2','3',
'4','5','6',
'7','8','9',
'*','0','#'
;
// this may be different on different keypads - please check!
byte rowPins[ROWS] = 11, 6, 7, 9; //connect to the row pinouts of the keypad
byte colPins[COLS] = 10, 12, 8; //connect to the column pinouts of the keypad
// attach keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
booleanisOpen=false; // flag determining the state of the lock
booleanisValid=false; // flag determining the validity of an input
char entryCode[4]='1','2','3','4'; // The code you need (overwritten from
EEPROM)
char inputB[4]='*','*','*','*'; // the keypad input buffer
inti;
long t=-1;
// set up the device
void setup()
Serial.begin(9600); // this is added for debugging - allows you to echo the keys
to the computer
pinMode(5,OUTPUT); //LED 1
pinMode(4,OUTPUT); //LED 2
pinMode(3,OUTPUT); //SOLENOID
Page 44
35
digitalWrite(3,LOW); // SOLENOID OFF
digitalWrite(4,LOW); //
digitalWrite(5,HIGH); // 4 LOW, 5 HIGH BI-COLOUR LED IS RED
/*
read code from EEPROM
IMPORTANT - initialise first otherwise you'll never get in!
*/
for (i=0;i<4;i++)
entryCode[i]=char(EEPROM.read(i));
void loop()
// t is the count-down timer. It is set when the lock is
// open and counts down to zero, at which point the lock is closed
if (t>0) t--;
if (t<=0)
isOpen=false;
digitalWrite(3,LOW); // SOLENOID OFF
digitalWrite(4,LOW);
digitalWrite(5,HIGH); // 4 LOW, 5 HIGH BI-COLOUR LED IS RED
char key = keypad.getKey(); // get a key (if pressed)
if (key)
Serial.println(key); // echo to computer fo debugging
if (key=='*') // if '*' check the last four digits are the entry code
Serial.println(inputB[0]);
Serial.println(inputB[1]);
Serial.println(inputB[2]);
Serial.println(inputB[3]);
// could do in a loop, but didn't!
if(inputB[0]==entryCode[0] &&
inputB[1]==entryCode[1] &&
inputB[2]==entryCode[2] &&
inputB[3]==entryCode[3] )
isOpen=true; // code ok - set open flag true
inputB[0]='*'; // reset input buffer
inputB[1]='*';
inputB[2]='*';
inputB[3]='*';
t=1000000; // reset countdown timer
else
isOpen=false; // code wrong - set open flag false
//isOpen=!isOpen;
if(isOpen)
digitalWrite(3,HIGH); // SOLENOID ON
digitalWrite(4,HIGH);
Page 45
36
digitalWrite(5,LOW); // 4 HIGH, 5 LOW BI-COLOUR LED IS GREEN
else
digitalWrite(3,LOW); // SOLENOID OFF
digitalWrite(4,LOW);
digitalWrite(5,HIGH); // 4 LOW, 5 HIGH BI-COLOUR LED IS RED
else
// a key other than '*' has been pressed
/*
lock is open and '#' pressed - store last 4 keys in eeprom as
new lock, but only if last 4 entries are digits
*/
if (isOpen&& key=='#')
// check a valid 4 digit code is in the iput buffer
isValid=true;
for (i=0;i<4;i++) if(inputB[i]=='*' || inputB[i]=='#') isValid=false;
if (isValid)
for (i=0;i<4;i++)
entryCode[i]=inputB[i]; // copy contents of input buffer to code buffer
EEPROM.write(i,entryCode[i]); // write the values in the EEPROM so they stay!
// flash LED to signal change
for (i=0;i<4;i++)
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
delay(500);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
delay(500);
else
// a digit has been pressed. First shift the contents of the key buffer
along...
for (i=0;i<3;i++)
inputB[i]=inputB[i+1]; // you lose the first key in the buffer doing this
inputB[3]=key; // ...then add the new key at the end of the list
Page 46
37
CHAPTER 4 - RESULT AND ANALYSIS
4.1 Introduction
This chapter presents the result and analysis of the whole project. This
process is required to determine the performance and achievement of the project.
The result must consider all objectives and scope that had been mention previous.
The analysis is based on problems encountered during project development and
the solution, comparison of overall project's result with project's objectives,
explanation on project's functionality or multifunction part and final result that
already achieve.
4.2 Result from Software
For programming simulation, the software that are used is Arduino
software because Arduino Nano was used in this project. After finished writing the
coding on the software, we run the coding by clicking run button. After the result
shows no error, it means there is no error on that coding and the next step in
upload which means the coding was uploaded into the microcontroller which is
Arduino Nano.
Page 47
38
4.3 Result from Hardware
The LED was red which means that the door was locked. After entering four digits
code, , the LED will green if the password is correct and will red if the password
entered was incorrect. When the LED is green, the door can be opened and timer
countdown will active and the door will automatically locked again when the timer
reaches zero.
4.4 Analysis
The result obtained from the project's function was same as wished. It runs
perfectly and follow all the principle written on the coding that was uploaded.
Figure 13 : when LED is red which means the door was locked
Page 48
39
Figure 14 : when LED is green which means the lock was opened
Page 49
40
CHAPTER 5-CONCLUSION AND SUGGESTION
5.1 Introduction
This chapter discuss about the conclusion and suggestion in the future
about their project. This project have two major parts which is hardware
description and software implementation. Both topics very well related and
important to each other and can be applied to perform the system more effective.
This chapter is very important because all the conclusion of overall project and
help to overcome the problem and improve the efficiency of the project in the
future.
5.2 Conclusion
Smart Lock For Controlled Medicine is one of option for medicine security
that was available in market. This project focuses on the patient's health by
securing and protect their medicine. The objective of this Smart Lock For
Controlled Medicine which are to make this project as a most important ingredients
in medical instrument, to upgrade medication storage with smart security system
instead of using keys, to reduce criminal among teens such as misuse drugs or
stolen at hospital, to ease doctor or parents to access to necessary drugs or
medicine safely and under control. Besides, to create a user friendly, inexpensive
security system and to increase the security level was successfully achieved.
In this project, the main component which is the CPU for this smart lock is
Arduino Nano and create the coding to program this project by using Arduino
software. The coding that was created has no errors and successfully uploaded
Page 50
41
into the microcontroller. The keypad that are used to enter the secret code is 3x4
keypad. Besides that, the other component that make this project succeed to run
are TIP 122 transistor, 12v relay and the magnetic lock.
The system was not too complicated and also easy to use. Their project
also has a different price which is affordable compared to the current medication
storage. However, this Smart Lock for Controlled Medicine was very durable and
easy to use.
5.3 Project Suggestion
The Smart Lock for Controlled Medicine have a lot of potential to be
developed in future for the community benefits. To upgrade this smart lock, maybe
by putting an alarm, if someone tried to open the medication storage by entering
the wrong password for two or three times, the alarm with turn on and the system
will send the message to the user.