Mini Project Report Digital Visitor Coun
Mini Project Report Digital Visitor Coun
Mini Project Report Digital Visitor Coun
On
Bachelor of Technology
in
Electronics & Communication Engineering
Submitted By
K.NAVEEN REDDY 137Z1A0441
K.SRIKANTH 137Z1A0443
B.MOHAN TEJA 137Z1A0457
SCHOOL OF ENGINEERING
2013-2017
Nalla Narasimha Reddy Group of Institutions
(Approved by AICTE and Affiliated to JNTU, Hyderabad)
Chowdariguda, Korremula, Ghatkesar-500088
CERTIFICATE
This is to certify that the project work entitled “ Digital Visitor counter using
8051 Microcontroller (AT89C51)” is submitted by
Name Regd. No
In partial fulfillment of the requirements for the award of the degree Bachelor of
Technology in Electronics and Communication Engineering, by Jawaharlal Nehru
Technological University, Hyderabad is a record of bonafide work carried out by them under my
guidance and supervision. The result embodied in this project report has not been submitted to any
other university or institute for the award of any degree.
SYNOPSIS
LIST OF FIGURES
LIST OF TABLES
ABBREVIATIONS
1 INTRODUCTION
1.1 Introduction 1
1.2 Problem statement 1
1.3 Motivation and challenges 1
1.4 Working of project 2
1.5 Circuit diagram 3
1.6 Project Objective 4
1.7 Components used 5
1.8 Organization of thesis 5
2 POWER SUPPLY
3 THE ARDUNIO
3.1 General 9
3.2 The History 9
3.3 Arduino description 10
3.3.1 Power 11
3.3.2 Memory 11
3.3.3 Input and Output 11
3.3.4 External Interrupts 12
3.3.5 Communication 12
3.3.6 ATmega328 Microcontroller 13
3.3.7 Block diagram 14
3.3.8 Pin Description 15
3.4 Programming in Arduino IDE 17
3.4.1 Port selection for PC 19
3.4.2 Board selection Arduino IDE 20
6 EXPERIMENTAL RESULTS
Main concept behind this project is known as “Visitor Counting” which measures the number
of persons entering in any room like seminar hall, conference room, classroom. This function is
implemented using a pair of Infrared sensors. LED display placed outside the room displays this
value of person count. This person count will be incremented if somebody enters inside the room
and at that time lights are turned on. In this way Relay does the operation of “Digital Visitor
counter”. Since this project uses 2 infrared sensors, it can be used as Bidirectional person
counter as well.
i
LIST OF FIGURES
Figure 3.5 This is the IDE user interface for programing Arduino boards 18
Figure 4.5 Show 10k potentiometer (a) and its circuit schematic (b) 26
ii
Figure 4.8.1 The optocupler 817c IC and its schematic with 33
pin description
to the IR module
the IR module
iii
LIST OF TABLES
iv
LIST OF ABBREVIATIONS
Rx Receiver
Tx Transaction
Vin Voltage (0 - 5 V)
Gnd Ground
HF High Frequency
Hz HERTZ
v
ROM Read Only Memory
R/W Read/Write
RST Reset
ID Identification
vi
DECLARATION
“We hereby declare that this submission is my own work and that, to the best of my
knowledge and belief, it contains no material previously published or written by another person nor
material which has been accepted for the award of any other degree or diploma of the university or
other institute of higher learning, except where due acknowledgment has been made in the text”.
CHAPTER-1
PROJECT INTRODUCTION
1.1 Introduction
Electricity is one of the most important resource in this century. Many times we need to
monitor the Electricity is one of the most important resources in this century. Many times we need
to monitor the person/people visiting some place like Auditorium. To provide solution for this we
are going to implement a project called “Digital Visitor Counter”. This project has a “Visitor
counter”. Main concept behind this project is to measure and display the number of persons
entering in any room like seminar hall, conference room. LCD display placed outside the room
displays number of person inside the room. This project can be used to count and display the
number of visitors entering inside any conference room or seminar hall. That means counter will
be incremented if person enters the room. We should conserve the electricity. Main concept behind
this project is to measure and display the number of persons entering in any room like seminar hall,
conference room. And when number of persons inside the room is zero, power supply inside the
room can be cut using a relay interface. This will help to save electricity. LED display placed
outside the room displays number of person inside the room.
Digital visitor counter is a reliable circuit that takes over the task of counting number of
persons/ visitors in the room passing through a single door and also turns ON led light. The total
number of persons inside the room is displayed on Seven Segment LED display.
Nowadays without electricity we cannot imagine our daily life because electricity has
become a necessity for all, without which day-to-day life chores & daily activities become stand
still. Due to the depletion of non-renewable resources, conservation of energy has become mandatory and
by doing so we can reduce electricity bills as well. We know that energies like wind energy, solar
energy and hydro energy are called renewable energy sources which are renewable in nature.
Therefore, utilization of these resources for power supply is the best possible way of producing,
conserving and renewing energy, which is advantageous as it is pollution free, affordable, and free
from environmental impacts. Nowadays without electricity we cannot imagine our daily life
because electricity has become a necessity for all, without which day-to-day life chores & daily
activities become stand still. Due to the depletion of non-renewable resources, conservation of energy
has become mandatory and by doing so we can reduce electricity bills as well. We know that energies
like wind energy, solar energy and hydro energy are called renewable energy sources which are
renewable in nature. Therefore, utilization of these resources for power supply is the best possible
way of producing, conserving and renewing energy, which is advantageous as it is pollution free,
affordable, and free from environmental impacts.
The basic block diagram of “Digital visitor counter” is shown in the figure. Mainly this
block diagram consists of the following essential blocks.
Micro-
Sensors Comparator 7 Segment
Controller
circuit display
AT89C51
Power supply
+5V
This project is divided in four parts: sensors, controller, counter display and gate. The
sensor would observe an interruption and provide an input to the controller which would run the
counter increment depending on entering of the person. And counting is displayed on a 7 Segment
LED through the controller. When any one enters in the room, IR sensor will get interrupted by the
object then other sensor will network because we have added a delay for a while he outputs of IR
Sensor Modules are directly connected to Comparator circuit to Micro controller digital pin number
9. LED is connected to pin number 21 to 27 PORT 3(AD1 to AD7) .Each transistors of LED
segment is connected to pin 1, 2&3.
This Project “Digital visitor counter” is a reliable circuit that takes over the task of counting
number of persons/ visitors in the room very accurately. When somebody enters into the room then
the counter is incremented by one.
The sensor would observe an interruption and provide an input to the controller which
would run the counter increment depending on entering of the person. And counting is displayed on
a 7 Segment LED through the controller. When any one enters in the room, IR sensor will get
interrupted by the object then other sensor will network because we have added a delay for a while
he outputs of IR Sensor Modules are directly connected to Micro-controller digital pin number
9(RST).Crystal Oscillator is connected to pin number 18 &19. LED is connected to pin number 21
to 27.
The total number of persons entering the room is displayed on the 7 segment LED displays.
The Micro-controller does the above job. It receives the signals from the sensors, and this signal is
operated under the control of software which is stored Micro-controller. Micro-controller
continuously monitor the Infrared Receivers, when any object passes through the IR Receiver's
then the IR Rays falling on the receiver are obstructed, this obstruction is sensed by the
Microcontroller on the board
The aim of this project is to count the objects (persons) entering the room and also switch
the led light accordingly. If we consider an office or a conference hall or any other room, we need
to turn on the lights whenever anybody enters the room. This is true even in the day time at some
places like conference halls or offices where a good brightness levels are desired. The problem is,
when the first person is entering a room.
This thesis has been organized into seven chapters. Chapter 1 introduces with our project
and explains the background review. Chapter 2 explains the power supply used in this project.
Chapter 3 explains Micro-controller, Chapter 4 and explains IR Modules. Chapter 5 explains LED
and USB serial communication approach. Chapter 6 explains the results and project outputs.
Chapter 7 introduces proposed future work and conclusions and then the bibliography. At last in
appendix codes are shown related to the project
CHAPTER-2
POWER SUPPLY
2.1 Parts of Power
By still use PCB and other equipment as before. To use transformer 1-2A. IC-78xx to Hold
Heatsink. For example, circuit that use IC-78xx series in fixed voltage supply for digital circuits. I
am built this dc regular circuit, is the first project. Because at that interesting about digital circuits,
need a constant 5V 1A fixed power supply. Using IC-7805 is very suitable for this job. Because it is
easy to use, easy to buy, as popular applications, and it is also cheap. For working principle, I
would have permitted to tell simply. When the home electric source ACV, 110V or 230V or a
220V, depending on your country, through the transformer, the voltage remains 12VAC. Then
through the diode for rectifier power supply to the DC Volt, And a filter circuit with Capacitors.
This is a voltage is about 12Vdc. It does not work through IC-7812, before our hero, for to control
a stable 12V voltage with can prevent also a short circuit. Just now I have a small circuit great
ready to use it.
Here this circuit diagram is for +12V regulated (fixed voltage) DC power supply.
This power supply circuit diagram is ideal for an average current requirement of 1Amp. This circuit
is based on IC LM7812. It is a 3-terminal (+ve) voltage regulator IC. It has short circuit protection,
thermal overload protection. LM7812 IC is from LM78XX series. The LM78XX series IC is
positive voltage regulator IC for different voltage requirements, for example LM7805 IC is made for 5
volt fixed output voltage . There is LM79XX IC series for negative voltage.
2.2 IC 7812:
The RS7812 can provide local on-card regulation, eliminating the distribution problems
associated with single point regulation. Each employs internal current limiting, thermal shut-down
safe operating area protection, making it essentially indestructible. If adequate heat sinking is
provided, they can deliver over 1A output current. Although designed primarily as fixed voltage
regulators, these devices can be used with external components to obtain adjustable voltages and
currents
CHAPTER-3
THE MICRO-CONTROLLER
3.1 General
The first microprocessor was the 4-bit Intel 4004released in 1971, with the Intel 8008 and other
more capable microprocessors becoming available over the next several years. However, both
processors required external chips to implement a working system, raising total system cost, and
making it impossible to economically computerize appliances. The Smithsonian
Institution credits TI engineers Gary Boone and Michael Cochran with the successful creation of
the first microcontroller in 1971. The result of their work was the TMS 1000, which became
commercially available in 1974. It combined read-only memory, read/write memory, processor and
clock on one chip and was targeted at embedded systems. Partly in response to the existence of the
single-chip TMS 1000, Intel developed a computer system on a chip optimized for control
applications, the Intel 8048, with commercial parts first shipping in 1977. It combined
RAM and ROM on the same chip. This chip would find its way into over one billion PC keyboards,
and other numerous applications. At that time Intel's President, Luke J. Valenter, stated that the
microcontroller was one of the most successful in the company's history, and expanded the
division's budget over 25%.Most microcontrollers at this time had concurrent variants. One had an
erasable EPROM program memory, with a transparent quartz window in the lid of the package to
allow it to be erased by exposure to ultraviolet light, often used for prototyping. The other was
either a mask programmed ROM from the manufacturer for large series, or a PROM variant which
was only programmable once; sometimes this was signified with the designation OTP, standing for
"one-time programmable". The PROM was of identical type of memory as the EPROM, but
because there was no way to expose it to ultraviolet light, it could not be erased. The erasable
versions required ceramic packages with quartz windows, making them significantly more
expensive than the OTP versions, which could be made in lower-cost opaque plastic packages. For
the erasable variants, quartz was required, instead of less expensive glass, for its transparency to
ultraviolet—glass is largely opaque to UV—but the main cost differentiator was the ceramic
package itself. In 1993, the introduction of EEPROM memory allowed microcontrollers (beginning
with the Microchip to be electrically erased quickly without an expensive package as required
for EPROM, allowing both rapid prototyping, and In System Programming. (EEPROM technology
had been available prior to this time, but the earlier EEPROM was more expensive and less
durable, making it unsuitable for low-cost mass-produced microcontrollers.) The same year, Atmel
introduced the first microcontroller using Flash memory, a special type of EEPROM. Other
companies rapidly followed suit, with both memory types. Cost has plummeted over time, with the
cheapest 8-bit microcontrollers being available for under 0.25 USD in quantity (thousands) in
2009, and some 32-bit microcontrollers around US$1 for similar quantities. Nowadays
microcontrollers are cheap and readily available for hobbyists, with large online communities
around certain processors. In the future, MRAM could potentially be used in microcontrollers as it
has infinite endurance and its incremental semiconductor wafer process cost is relatively low.
3.3.1 Interrupts:
Microcontrollers must provide real time (predictable, though not necessarily fast) response to
events in the embedded system they are controlling. When certain events occur, an interrupt system
can signal the processor to suspend processing the current instruction sequence and to begin
an interrupt service routine (ISR, or "interrupt handler") which will perform any processing
required based on the source of the interrupt, before returning to the original instruction sequence.
Possible interrupt sources are device dependent, and often include events such as an internal timer
overflow, completing an analog to digital conversion, a logic level change on an input such as from
a button being pressed, and data received on a communication link. Where power consumption is
important as in battered devices, interrupts may also wake a microcontroller from a low-power
sleep state where the processor is halted until required to do something by a peripheral event.
Programs: Typically microcontroller programs must fit in the available on-chip memory, since it
would be costly to provide a system with external, expandable memory. Compilers and assemblers
are used to convert both high-level and assembly language codes into a compact machine code for
storage in the microcontroller's memory. Depending on the device, the program memory may be
permanent, read-only memory that can only be programmed at the factory, or it may be field-
alterable flasher erasable read-only memory. Manufacturers have often produced special versions
of their microcontrollers in order to help the hardware and software development of the target
system. Originally these included EPROM versions that have a "window" on the top of the device
through which program memory can be erased by ultraviolet light, ready for reprogramming after a
programming ("burn") and test cycle. Since 1998, EPROM versions are rare and have been
replaced by EEPROM and flash, which are easier to use (can be erased electronically) and cheaper
to manufacture. Other versions may be available where the ROM is accessed as an external device
rather than as internal memory, however these are becoming rare due to the widespread availability
of cheap microcontroller programmers. The use of field-programmable devices on a
microcontroller may allow field update of the firmware or permit late factory revisions to products
that have been assembled but not yet shipped. Programmable memory also reduces the lead time
required for deployment of a new product. Where hundreds of thousands of identical devices are
required, using parts programmed at the time of manufacture can be economical. These "mask
programmed" parts have the program laid down in the same way as the logic of the chip, at the
same time. A customizable microcontroller incorporates a block of digital logic that can be
personalized for additional processing capability, peripherals and interfaces that are adapted to the
requirements of the application. One example is the AT91CAP from Atmel.
Microcontrollers usually contain from several to dozens of general purpose input/output pins
(GPIO). GPIO pins are software configurable to either an input or an output state. When GPIO pins
are configured to an input state, they are often used to read sensors or external signals. Configured
to the output state, GPIO pins can drive external devices such as LEDs or motors, often indirectly,
through external power electronics. Many embedded systems need to read sensors that produce
analog signals. This is the purpose of the analog-to-digital converter (ADC). Since processors are
built to interpret and process digital data, i.e. 1s and 0s, they are not able to do anything with the
analog signals that may be sent to it by a device. So the analog to digital converter is used to
convert the incoming data into a form that the processor can recognize. A less common feature on
some microcontrollers is a digital-to-analog converter (DAC) that allows the processor to output
analog signals or voltage levels. In addition to the converters, many embedded microprocessors
include a variety of timers as well. One of the most common types of timers is the Programmable
Interval Timer (PIT). A PIT may either count down from some value to zero, or up to the capacity
of the count register, overflowing to zero. Once it reaches zero, it sends an interrupt to the
processor indicating that it has finished counting. This is useful for devices such as thermostats,
which periodically test the temperature around them to see if they need to turn the air conditioner
on, the heater on, etc. A dedicated Pulse Width Modulation (PWM) block makes it possible for the
CPU to control power converter, resistive loads, motors, etc., without using lots of CPU resources
in tight timer loops. Universal Asynchronous Receiver/Transmitter (UART) block makes it
possible to receive and transmit data over a serial line with very little load on the CPU. Dedicated
on-chip hardware also often includes capabilities to communicate with other devices (chips) in
digital formats such as Inter-Integrated Circuit , Serial Peripheral Interface (SPI), Universal Serial
Bus (USB), and Ethernet.
Many microcontrollers are so quirky that they effectively require their own non-standard dialects of
C, such as SDCC for the 8051, which prevent using standard tools (such as code libraries or static
analysis tools) even for code unrelated to hardware features. Interpreters are often used to hide such
low level quirks. Interpreter firmware is also available for some microcontrollers. For
example, basic on the early microcontrollers Intel 8052, basic and forth on the Zilog Z8as well as
some modern devices. Typically these interpreters support interactive programming. Simulators are
available for some microcontrollers. These allow a developer to analyze what the behavior of the
microcontroller and their program should be if they were using the actual part. A simulator will
show the internal processor state and also that of the outputs, as well as allowing input signals to be
generated. While on the one hand most simulators will be limited from being unable to simulate
much other hardware in a system, they can exercise conditions that may otherwise be hard to
reproduce at will in the physical implementation, and can be the quickest way to debug and analyze
problems. Recent microcontrollers are often integrated with on-chip debug circuitry that when
accessed by an in-circuit emulator via JTAG, allow debugging of the firmware with a debugger. A
real-time ICE may allow viewing and/or manipulating of internal states while running. A tracing
ICE can record executed program and MCU states before/after a trigger point.
started.
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial
driver chip. Instead, it features the Atmega8U2 programmed as a USB-to-serial converter.
"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The
Uno and version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the
latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a
comparison with previous versions, see the index of Arduino boards.
3.3.1 Power
The Arduino Uno 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 center-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 of 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may be 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 Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or another regulated power source). You can supply
voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.
5V. The regulated power supply used to power the microcontroller and other components
on the board. This can come either from VIN via an on-board regulator, or be supplied by USB or
another regulated 5V supply.
3V3. A 3.3-volt supply generated by the on-board regulator. Maximum current draw is 50
mA.
GND. Ground pins.
3.3.2 Memory
Since the emergence of microcontrollers, many different memory technologies have been used.
Almost all microcontrollers have at least two different kinds of memory, a non-volatile memory for
storing firmware and a read-write memory for temporary data.
Each of the 14 digital pins on the Uno can be used as an input or output,
using pinMode(), digitalWrite(), anddigitalRead() functions. They operate at 5 volts. Each pin can provide or
receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-
50 kOhms. In addition, some pins have specialized functions:
Serial: 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.
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. See the attachInterrupt () function for details.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.
The Uno has 6 analog inputs, labeled 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 is it
possible to change the upper end of their range using the AREF pin and the analogReference() function.
Additionally, some pins have specialized functionality:
I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication using the Wire library.
AREF. Reference voltage (0 to 5V only) for the analog inputs. Used with analog Reference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button
to shields which block the one on the board.
3.3.5 Communication
The Arduino Uno has a number of facilities for communicating with a computer, another
Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial
communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the
board channels this serial communication over USB and appears as a virtual com port to software
on the computer. The '8U2 firmware uses the standard USB COM drivers, and no external driver is
needed. However, on Windows, a .inf file is required. The Arduino software includes a serial monitor which
allows simple textual data to be sent to and from the Arduino 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 (but not for serial communication on pins 0 and 1).
A Software Serial library allows for serial communication on any of the Uno's digital pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software includes
a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI communication,
use the SPI library.
The AVR core combines a rich instruction set with 32 general purpose working registers.
All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two
independent registers to be accessed in one single instruction executed in one clock cycle. The
resulting architecture is more code efficient while achieving throughputs up to ten times faster than
conventional CISC microcontrollers
It has 14 digital I/O pins, of which 6 can be used as PWM outputs and 6 analog input pins.
These I/O pins account for 20 of the pins. As stated before, 20 of the pins function as I/O ports.
This means they can function as an input to the circuit or as output. Whether they are input or
output is set in the software. 14 of the pins are digital pins, of which 6 can function to give PWM
output. 6 of the pins are for analog input/output. Two of the pins are for the crystal oscillator. This
is to provide a clock pulse for the Atmega chip. A clock pulse is needed for synchronization so that
communication can occur in synchrony between the Atmega chip and a device that it is connected
to The chip needs power so 2 of the pins, Vcc and GND, provide it power so that it can operate.
The Atmega328 is a low-power chip, so it only needs between 1.8-5.5V of power to operate
CHAPTER-4
IR MODULES
4.1 Introduction
An infrared sensor is an electronic device that emits in order to sense some aspects of the
surroundings. An IR sensor can measure the heat of an object as well as detects the motion. These
types of sensors measure only infrared radiation, rather than emitting it that is called as a passive IR
sensor. Usually in the infrared spectrum, all the objects radiate some form of thermal radiations.
These types of radiations are invisible to our eyes, that can be detected by an infrared sensor. The
emitter is simply an IR LED (Light Emitting Diode) and the detector is simply an IR photodiode which is
sensitive to IR light of the same wavelength as that emitted by the IR LED. When IR light falls on
the photodiode, the resistances and these output voltages, change in proportion to the magnitude of
the IR light received.
In this project, the transmitter section includes an IR sensor, which transmits continuous IR
rays to be received by an IR receiver module. An IR output terminal of the receiver varies
depending upon its receiving of IR rays. Since this variation cannot be analyzed as such, therefore
this output can be fed to a comparator circuit. Here an operational (op-amp) of LM 339 is used as
comparator circuit
When the IR receiver does not receive a signal, the potential at the inverting input goes
higher than that non-inverting input of the comparator IC (LM339). Thus the output of the
comparator goes low, but the LED does not glow. When the IR receiver module receives signal to
the potential at the inverting input goes low. Thus the output of the comparator (LM 339) goes high
and the LED starts glowing. Resistor R1 (100), R2 (10k) and R3 (330) are used to ensure that
minimum 10 mA current passes through the IR LED Devices like Photodiode and normal LEDs
respectively. Resistor VR2 (preset=5k) is used to adjust the output terminals. Resistor VR1
(preset=10k) is used to set the sensitivity of the circuit Diagram. Read more about IR sensors.
4.2.1 LM358
The LM358 op-amps are used in transducer amplifiers, dc gain blocks and all the
conventional op-amp circuits which now can be more easily implemented in single power supply
systems. For example, the LM358 op-amp can be directly operated off of the standard +5V power
supply voltage which is used as a part of digital systems and will easily provide the required
interface electronics without needing the extra ±15V power supplies.
Pin Description:
Wide bandwidth
Wide power supply range: single supply: 3V to 32V
Very low supply current drain essentially independent of supply voltage
Low input offset voltage: 2 mV
Input common-mode voltage range includes ground
Differential input voltage ranges equal to the power supply voltage
The inverting input of the comparator LM358 i.e., pin 2 is given to the fixed voltage i.e., in
the ratio 47k:10k and the non-inverting input of the comparator is pulled down and is given to
sensing terminal. When the resistance between the positive supply and the non-inverting input is
high then resulting is the non-inverting input less than the inverting input making comparator output
as logic low at pin1. And when the resistance falls making available a voltage to the non-inverting
input higher than inverting input, so that the output of comparator is logic high.
4.3 IR LED
The appearance is same as a common LED. Since the human eye cannot see the infrared
radiations, it is not possible for a person to identify whether the IR LED is working or not, unlike a
common LED. To overcome this problem, the camera on a cellphone can be used. The camera can
show us the IR rays being emanated from the IR LED in a circuit.
Potentiometer (Pot) is another class of variable resistors and is used as an adjustable voltage
divider. It consists of a fixed resistance track having connections at both ends and a sliding contact,
called wiper, which moves along this track by turning the spindle. If only one of the connections
and wiper are used, it behaves as a variable resistor or rheostat. In case wiper is not used, it
willoffer fixed resistance across the two connections. They are specified by their fixed value
resistance.
(a) (b)
Figure 4.5: Show 10k Potentiometer (a) And Its Circuit Schematic (b)
IR sensors are used in various Sensor based projects and also in various electronic devices
Radiation Thermometers
Flame Monitors
Moisture Analyzers
Gas Analyzers
Dispersive
Non dispersive
IR Imaging Device
Relay is an electromagnetic device which is used to isolate two circuits electrically and
connect them magnetically. They are very useful devices and allow one circuit to switch another
one while they are completely separate. They are often used to interface an electronic circuit
(working at a low voltage) to an electrical circuit which works at very high voltage. For example, a
relay can make a 5V DC battery circuit to switch a 230V AC mains circuit. Thus a small sensor
circuit can drive, say, a fan or an electric bulb.
A relay switch can be divided into two parts: input and output. The input section has a coil
which generates magnetic field when a small voltage from an electronic circuit is applied to it. This
voltage is called the operating voltage. Commonly used relays are available in different
configuration of operating voltages like 6V, 9V, 12V, 24V etc. The output section consists of
contactors which connect or disconnect mechanically. In a basic relay there are three contactors:
normally open (NO), normally closed (NC) and common (COM). At no input state, the COM is
connected to NC. When the operating voltage is applied the relay coil gets energized and the COM
changes contact to NO. Different relay configurations are available like SPST, SPDT, DPDT etc.,
which have different number of changeover contacts. By using proper combination of contactors,
the electrical circuit can be switched on and off. Get inner details about structure of a relay switch.
As soon as the coil current is off, the movable armature will be returned by a force back to
its initial position. This force will be almost equal to half the strength of the magnetic force. This
force is mainly provided by two factors. They are the spring and also gravity
The working of a relay can be better understood by explaining the following diagram given
below. The diagram shows an inner section diagram of a relay. An iron core is surrounded by a
control coil. As shown, the power source is given to the electromagnet through a control switch and
through contacts to the load. When current starts flowing through the control coil, the
electromagnet starts energizing and thus intensifies the magnetic field. Thus the upper contact arm
starts to be attracted to the lower fixed arm and thus closes the contacts causing a short circuit for
the power to the load. On the other hand, if the relay was already de-energized when the contacts
were closed, then the contact move oppositely and make an open circuit
Relays are mainly made for two basic operations. One is low voltage application and the
other is high voltage. For low voltage applications, more preference will be given to reduce the
noise of the whole circuit. For high voltage applications, they are mainly designed to reduce a
phenomenon called arcing. Two terminals are used to give the input DC voltage also known as the
operating voltage of the relay. Relays are available in different operating voltages like 6V, 12V, 24V
etc. The rest of the three terminals are used to connect the high voltage AC circuit. The terminals
are called Common, Normally Open (NO) and Normally Closed (NC).
The basics for all the relays are the same. Take a look at a 4 – pin relay shown below. There
are two colors shown. The green color represents the control circuit and the red color represents the
load circuit. A small control coil is connected onto the control circuit. A switch is connected to the
load. This switch is controlled by the coil in the control circuit. Now let us take the different steps
that occur in a relay.
As shown in the circuit, the current flowing through the coils represented by pins 1 and 3
causes a magnetic field to be aroused. This magnetic field causes the closing of the pins 2 and 4.
Thus the switch plays an important role in the relay working. As it is a part of the load circuit, it is
used to control an electrical circuit that is connected to it. Thus, when the relay in energized the
current flow will be through the pins 2 and 4.
As soon as the current flow stops through pins 1 and 3, the switch opens and thus the open
circuit prevents the current flow through pins 2 and 4. Thus the relay becomes de-energized and
thus in off position.
Relays have the exact working of a switch. So, the same concept is also applied. A relay is
said to switch one or more poles. Each pole has contacts that can be thrown in mainly three ways.
They are
Normally Open Contact (NO) – NO contact is also called a make contact. It closes the
circuit when the relay is activated. It disconnects the circuit when the relay is inactive.
Normally Closed Contact (NC) – NC contact is also known as break contact. This is
opposite to the NO contact. When the relay is activated, the circuit disconnects. When the relay is
deactivated, the circuit connects.
Change-over (CO) / Double-throw (DT) Contacts – This type of contacts is used to control
two types of circuits.
They are used to control a NO contact and also a NC contact with a common terminal.
According to their type they are called by the names break before make and make before
break contacts.
Single Pole Single Throw (SPST) – This type of relay has a total of four terminals. Out of
these two terminals can be connected or disconnected. The other two terminals are needed for the
coil.
Single Pole Double Throw (SPDT) – This type of a relay has a total of five terminals. Out
of these two are the coil terminals. A common terminal is also included which connects to either of
two others.
Double Pole Single Throw (DPST) – This relay has a total of six terminals. These terminals
are further divided into two pairs. Thus they can act as two SPST’s which are actuated by a single
coil. Out of the six terminals two of them are coil terminals. Double Pole Double Throw (DPDT) –
This is the biggest of all. It has mainly eight relay terminals. Out of these two rows are designed to
be change over terminals. They are designed to act as two SPDT relays which are actuated by a
single coil.
This is a 5V 4-channel relay interface board, and each channel needs a 15-20mA driver
current. It can be used to control various appliances and equipment with large current. It is
equipped with high-current relays that work under AC250V 10A or DC30V 10A.
From the picture below, you can see that when the signal port is at low level, the signal light
will light up and the optocoupler 817c (it transforms electrical signals by light and can isolate input
and output electrical signals) will conduct, and then the transistor will conduct, the relay coil will
be electrified, and the normally open contact of the relay will be closed. When the signal port is at
high level, the normally closed contact of the relay will be closed. So you can connect and
disconnect the load by controlling the level of the control signal port.
Input:
Output:
The module is supplied with power via the pin labeled VCC and ground via the pin labeled
GND. The relays are energized with low inputs to the IN1, IN2, IN3 and IN4 inputs
There are four relays that each provide dry contact outputs. That is to say that each relay
provides a common (COM), normally open (NO) and a normally closed (NC) terminal.
purpose of an optocoupler is to transfer signals from one circuit to another yet keep them galvanically
isolated.
Figure 4.7.1: The optocupler 817c IC And Its Schematic with Pin Description
4.9 Relay Applications
Relays are used to realize logic functions. They play a very important role in providing
safety critical logic.
Relays are used to provide time delay functions. They are used to time the delay open and
delay close of contacts.
Relays are used to control high voltage circuits with the help of low voltage signals.
Similarly, they are used to control high current circuits with the help of low current signals.
They are also used as protective relays. By this function all the faults during transmission
and reception can be detected and isolated.
CHAPTER-5
LIQUID CRYSTAL DISPLAY AND USB
5.1 Introduction to LCD
LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range
of applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi segment LEDs.
The reasons being: LCDs are economical; easily programmable; have no limitation of displaying
special & even custom characters (unlike in seven segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data. The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it, clearing its
screen, setting the cursor position, controlling display etc. The data register stores the data to be
displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.
Click to learn more about internal structure of a LCD.
Their programming is also same and they all have same 14 pins (0-13) or 16 pins(0to15). There
are Eight (8) Data pins
3 Pin 3 (VEE) This is the pin for adjusting a contrast of the LCD display by
attaching a variable resistor in between VCC and GND.
4 Pin 4 (RS) RS stands for Register Select. This pin is used to select
command/data register.
If RS=0 then command register is selected.
If RS=1 then data register is selected.
5 Pin 5 (R/W) R/W stands for Read/Write. This pin is used to select the
operation Read/Write.
If R/W=0 then Write operation is performed.
If R/W=1 then Read operation is performed.
6 Pin 6 (EN) En stand for Enable signal. A positive going pulse on this pin
will perform a read/write function to the LCD.
7 Pin 7-14 (DB0-DB7) This 8 pin is used as a Data pin of LCD.
8 Pin 15 (LED+) This pin is used with pin 16(LED-) to setting up the
illumination of back light of LCD. This pin is connected with
VCC.
9 Pin 16 (LEC-) This pin is used with pin 15(LED+) to setting up the
illumination of back light of LCD. This pin is connected with
GND.
LiquidCrystal(_),begin(_),clear(_),home(_),setCursor(_),write(_),print(_),cursor(_),noCursor(_),blink(_),noBlink(_)display(_),noDisplay(_),scrol
The Liquid Crystal Library allows you to control LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them obove there, and you can usually tell them by the
16-pin interface. This project shows how to use the display () and noDisplay () methods to turn on
and off the display. The text to be displayed will still be preserved when you use noDisplay () so
it's a quick way to blank the display without losing everything on it.
In this circuit, the LCD terminals are connected to the Arduino pins according to the table
below. Connect the outer two terminals of the potentiometer to 5V and ground, and the
middle terminal to pin 3 of LCD. Rotating the potentiometer controls the brightness of the LCD
backlight. The LCD back light pins are connected to 5V and ground as shown in the diagram
below:
DB4----->pin4
DB5----->pin5
DB6----->pin6
DB7----->pin7
RS-----> pin8
EN-----> pin9
Universal Serial Bus (USB) is a set of interface specifications for high speed wired
communication between electronics systems peripherals and devices with or without PC/computer.
The USB was originally developed in 1995 by many of the industry leading companies like Intel,
Compaq, Microsoft, Digital, IBM, and Northern Telecom.
The major goal of USB was to define an external expansion bus to add peripherals to a PC
in easy and simple manner. The new external expansion architecture, highlights,
Arduino use the USB port to simulate a serial port so we have to use a USB cable to
connect the Arduino USB port to computer USB port.
Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the
board). Don't connect these pins directly to anRS232 serial port; they operate at +/- 12V and can
damage your Arduino board.
Serial is used for communication between the Arduino board and a computer or other
devices. All Arduino boards have at least one serial port (also known as a UART or USART):
Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB
This board converts a USB connection into 5 volt TX and RX that you can connect straight
to the Arduino Mini or other microcontrollers, allowing them to talk to the computer. It is based on
the FT232RL chip from FTDI (drivers are included with the Arduino software).
Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output.
You can use the Arduino environment's built-in serial monitor to communicate with an Arduino
board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to
begin ().
Serial communication works on 1s and 0s. Also known as binary, the Arduino sends these
1s and 0s (bits) one by one, or Serially. These bits are sent in the form of Highs (1) and Lows (0).
These bits’ form together and turn into bytes. A byte is composed of 8 bits.
Similarly:
100 = 4,
1000 = 8,
10000 = 16,
100000 = 32,
1000000 = 64
10000000 = 128.
Write (): -Writes binary data to the serial port. This data is sent as a byte or series of bytes; to send
the characters representing the digits of a number use the print() function instead.
Print (): -Prints data to the serial port as human-readable ASCII text. This command can take
many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly
printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character
read (): -Reads incoming serial data. read () inherits from the Stream utility class.
EXPERIMENTAL RESULTS
AUTOMATIC ROOM APPLIANCE CONTROL WITH BIDIRECTIONAL VISITOR COUNTER
Chapter 6
EXPERIMENTAL RESULTS
This chapter contains the results conducted and discusses the obtained results. The proposed
approach has been evaluated on the results in the below.
Sketch uses 3,238 bytes (10%) of program storage space. Maximum is 32,256 bytes.
Global variables use 121 bytes (5%) of dynamic memory, leaving 1,927 bytes for local
variables. Maximum is 2,048 bytes.
The program is stored in DRAM in the Arduino by taking 32385 bytes of the total memory
space that is 10% of 32256 bytes for the execution of the program. The program is store until
another program is dumped into the board. The program can be rested by pressing the reset button
on the board
The notes on this page are for all boards except the Due, which has a different architecture
There are three pools of memory in the microcontroller used on AVR-based Arduino boards:
Here all the four relays are high and number of persons are increased and the appliance can
be ON The connected appliance are switched on. The appliances get OFF if persons leave the
Room shown below
Figure 6.2: Assuming A Person Entering into Room as an Obstacle to The IR Module
Here the relay and the appliances gets turn off by decrementing the number of persons in
the room automatically by sensing from IR modules.
Figure 6.3 Assuming A Person Leaving from Room as an Obstacle to The IR Module
The maximum number of person entering and leaving from the room is limited by 32767
and maximum number of appliance controlled is 4
Chapter 7
CONCLUSION AND PROPOSED FUTURE SCOPE
7.1 CONCLUSION
The theme of the project when merged with certain established technologies can be quite
effective in number of countries like Germany, Japan and France etc., which control the train. The
project is useful in developing countries and this project has a bright future. This project helps us to
control the light, fan, and home appliance automatically and counts the number of persons entering
and leaving the room by modifying this circuit and using four relays we can achieve a task of
opening and closing the door and can be implemented to every high voltage controllable appliance
which has to automated by sensing.
We can send this data to a remote location using mobile or internet. Voice alarm system can
be added to indicate that room is full and persons can’t enter inside. We can increase the maximum
number of persons that can be counted by implementing the EEPROM in Arduino. We can add a
Bluetooth module for communication This can be basic for home automation system Making
android app and connecting and operation can be done Using for INTERNET OF THINGS(IOT)
The board may be extended and module can be upgraded. By using this circuit and proper power
supply we can implement various applications such as fans, tube lights, etc. By modifying this
circuit and using two relays we can achieve a task of opening and closing the door.
BIBLIOGRAPHY
[1] Muhammad Ali Mazidi “AVR Microcontroller and Embedded Systems Using Assembly and C”
Pearson Custom Electronics Technology 1st ed. Edition
[2] Alan Trevennor “Practical AVR Microcontrollers Games, Gadgets, and Home Automation with
the Microcontroller Used in the Arduino” Technology in Action 1st ed. Edition.
[4] https://www.sunfounder.com/wiki
[5]http://www.keepjump.com.tw/
[6]https://www.arduino.cc .
[7]https://www.fairchildsemi.com/datasheets./
[8]https://en.wikipedia.org/wiki
[9]https://www.sparkfun.com
[10]https://www.sunfounder.com/wiki
[11]http://www.atmel.com/about/corporate/university/books.aspx
[12]https://www.arduino.cc/en/Tutorial/HomePage
[13] http://www.talkingelectronics.com/te_interactive_index.html
APPENDIX
#include<LiquidCrystal.h>
LiquidCrystal lcd(8, 7, 6, 5, 4, 3);
#define in 14
#define out 19
#define re1 9
#define re2 10
#define re3 11
#define re4 12
int count=0;
void setup()
{
lcd.begin(16,2);
lcd.print("WELCOME EVERYONE");
lcd.setCursor(0,1);
lcd.print("ROOM IS EMPTY");
delay(2000);
pinMode(in, INPUT);
pinMode(out, INPUT);
pinMode(re1,OUTPUT);
pinMode(re2,OUTPUT);
pinMode(re3,OUTPUT);
pinMode(re4,OUTPUT);
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
}
void loop()
{
if(digitalRead(in))
IN();
if(digitalRead(out))
OUT();
if(count<=0)
{
lcd.clear();
digitalWrite(re1, HIGH);
digitalWrite(re2, HIGH);
digitalWrite(re3, HIGH);
digitalWrite(re4, HIGH);
lcd.clear();
lcd.print("Nobody In Room");
lcd.setCursor(0,1);
lcd.print("SAVE ENRGY !!!!");
delay(200);
}
else
digitalWrite(re1, LOW);
digitalWrite(re2, LOW);
digitalWrite(re3, HIGH);
digitalWrite(re4, HIGH);
if(count>2 )
{
digitalWrite(re1, LOW);
digitalWrite(re2, LOW);
digitalWrite(re3, LOW);
digitalWrite(re4, LOW);
}
void IN()
{
count++;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void OUT()
{
count--;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}