Sunteți pe pagina 1din 57

[Type the document

title]
[Type the document subtitle]

[Type the abstract of the document here. The abstract is


typically a short summary of the contents of the document.
Type the abstract of the document here. The abstract is
typically a short summary of the contents of the
document.]

HP D017TU
[Pick the date]
ACKNOWLEDGEMENT

I am deeply thankful to “TECHIES Institute” as it has given me a


golden opportunity to go through remarkable training on
“Embedded Systems” “ARDUINO”. Here I have got valuable and
detailed knowledge on real time projects. I owe my gratitude to my
faculty cum trainer “Mr. Anurag “for his unmatched support,
guidance and Inspiration without which I would not have learned so
many new and Innovative things in such a short span of time.

I would also like to thank Department of Electronics and


communication Engineering, Guru Nanak Dev University especially
my H.O.D. “Mr. M.L Singh”, and all my teachers who suggested me to
join the beneficial summer training. My special thank to our Class
incharge and Training incharge without whose support I would not
have prepared this Report on time in such a good way.

I am highly obliged that I have received all of your support in such a


good way.

Yours Faithfully

Apoorva Rampal

UnivRollno.2014ECA1011

1
INDEX
S.NO CONTENTS PAGE NO.

1. Training objective 2

2. Brief of organisation 3

3. Introduction to embedded systems 5

4. Arduino a detailed approach 6

5. Arduino interfacing 26

6. Applications of arduino 43

7. Project description 49

8. Snapshots of project 54

9. Bibliography 55

2
TRAINING OBJECTIVE

I decided to undergo the summer training in Embedded Systems


(ARDUINO) as this provides a detailed and practical knowledge in the
field of latest upcoming technology; I took the training through
Techies Institute Amritsar under the guidance of Mr. Anurag.

My main objective of undergoing the training was to gain a practical


understanding and a platform where I can polish my work and can
make a real time working project. The 6 week training on Arduino
opened a vast platform of opportunities for me and provided a base
on which I can work upon and enhance my skills.

The training proved to be a great learning experience and provided


me with a vast knowledge of latest technology in the field of
embedded systems. Arduino is a platform which has a huge
following and this also helped to learn very innovative ideas from
great minds around the world.

With increasing competition in every field it becomes very important


to have an updated and clear vision in the field we are working, and
the decision of doing training in arduino proved to be a remarkable
starting step towards a brighter future by providing a great platform
to enhance my knowledge in this cutting edge and in demand
technology.

I made a real time working project to check my learning and practical


skills and with the successful completion of my project “SMART
HOME” i was able to use my learnings from the training successfully
and this added one more positive point in my student life.

3
EMBEDDED SYSYTEMS

Embedded systems are commonly found in consumer, cooking, industrial,


automotive, medical, commercial and military applications.
Telecommunications systems employ numerous embedded systems
from telephone switches for the network to cell phones at the end-user.
Computer networking uses dedicated routers and network bridges to route
data.

Embedded systems are used in transportation, fire safety, safety and security,
medical applications and life critical systems, as these systems can be isolated
from hacking and thus, be more reliable. For fire safety, the systems can be
designed to have greater ability to handle higher temperatures and continue to
operate. In dealing with security, the embedded systems can be self-sufficient
and be able to deal with cut electrical and communication systems.

A new class of miniature wireless devices called motes are networked wireless
sensors. Wireless sensor networking, WSN, makes use of miniaturization made
possible by advanced IC design to couple full wireless subsystems to
sophisticated sensors, enabling people and companies to measure a myriad of
things in the physical world and act on this information through IT monitoring
and control systems

Embedded systems are designed to do some specific task, rather than be a


general-purpose computer for multiple tasks. Some also have real-
time performance constraints that must be met, for reasons such as safety and
usability; others may have low or no performance requirements, allowing the
system hardware to be simplified to reduce costs.

4
ARDUINO
Arduino interface boards provide the engineers,artists,designers,hobbyists
and anyone who tinker with technology with a low-cost,easy-to-use technology
to create their creative,interactive objects,useful projects etc.,A whole new
breed of projects can now be built that can be controlled from a computer.

1.1 WHAT IS ARDUINO?

Figure 1.1 ARDUINO UNO

Arduino is a open source electronics prototyping platform based on


flexible,easy-to-use hardware and software. It’s intended for
artists,designers,hobbyists,and anyone interested in creating interactive objects
or environments.It’s an open-source physical computing platform based on a
microcontroller board, and a development environment for writing software for
the board.

In simple words, Arduino is a small microcontroller board with a USB plug


to connect to your computer and a number of connection sockets that can be
wired up to external electronics, such as motors, relays, light sensors, laser
diodes, loudspeakers, microphones, etc. They can either be powered through the
USB connection from the computer or from a 9V battery.They can be controlled

5
from the computer or programmed by the computer and then disconnected and
allowed to work independently.

Anyone can buy this device through online auction site or search engine.
Since the Arduino is an open-source hardware designs and create their own
clones of the Arduino and sell them, so the market for the boards is competitive
.An official Arduino costs about $30,and a clone often less than $20.

The name “Arduino” is reserved by the original makers. However, clone


Arduino designs often have the letters “duino” on the end of their name, for
example, Freeduino or DFRduino. The software for programming your Arduino
is easy to use and also freely available for Windows, Mac, and LINUX
computers at no cost.

1.1.1 Microcontroller
Microcontroller can be described as a computer embedded on a rather
small circuit board. To describe the function of a microcontroller more
precisely, it is a single chip that can perform various calculations and tasks, and
send/receive signals from other devices via the available pins. Precisely what
tasks and communication with the world it does, is what is governed by what
instructions we give to the Microcontroller. It is this job of telling the chip what
to do, is what we refer to as programming on it.
However, the uC by itself cannot accomplish much; it needs several external
inputs: power, for one; a steady clock signal, for another. Also, the job of
programming it has to be accomplished by an external circuit. So typically, a uC
is used along with a circuit which provides these things to it; this combination is
called a microcontroller board. The Arduino Uno that you have received is one
such microcontroller board. The actual microcontroller at its heart is the chip

6
called Atmega328. The advantages that Arduino offers over other
microcontroller boards are largely in terms of reliability of the circuit hardware
as well as the ease of programming and using it.

1.1.2 Open-source hardware


Open-source hardware shares much of the principles and approach of free
and open-source software.The founders of Arduino wanted people to study their
hardware, to understand how it works, make changes to it, and share those
changes with the world. To facilitate this, they release all of the original design
files (Eagle CAD) for the Arduino hardware. These files are licensed under a
Creative Common Attribution Share-Alike license, which allows for both
personal and commercial derivative works, as long as they (people) credit
Arduino and release their designs under the same license.
The Arduino software is also open-source.The source code for the Java
environment is released under the GPL and the C/C++ microcontroller libraries
are under the LGPL

HISTORY OF ARDUINO
While teaching a physical computing class at the Interaction Design Institute
Ivrea in 2005, Massimo Banzi’s students were unwilling to spend the 76 euros
for the BASIC Stamp microcontrollers commonly used in such applications.
Banzi and his collegues looked for alternatives, finally settling on the wiring
platform developed by one of Banzi’s students. In his own words:
“…we started to figure out how we could make the whole platform even
simpler, even cheaper, and even easier to use. And then we started to essentially
reimplement the whole thing as an open source project.”
Once they had a prototype, a student wrote the software that would allow wiring
programs to run on the new platform. Upon seeing the project, visiting professor

7
Casey Reas suggested that there might be wider applications than just design
schools for the new product. The prototype was redesigned for mass production
and a test run of 200 boards was made. Orders began coming in from other
design schools and the students looking for Arduinos, and the Arduino project
was born and Massimo Banzi and David Cuartielles became its
founders.”ARDUINO” is an Italian word, meaning “STRONG FRIEND”.The
English version of the name is “Hardwin”. As of May 2011, more than 300,000
Arduino units are “in the wild”.
1.2.1 Design Goals
 Work with a Mac (as most design students use one)
 USB connectivity (MacBooks don’t have serial ports
 Look nice
 Cheap (about 20 euros, the cost of going out for pizza in Europe)
 More powerful than a BASIC stamp
 Something you could build/fix yourself
Simple and easy to use by someone without formal electronics training
1.2.2 Business Models
Since the entire project is open source, anyone can build and sell
Arduino-compatible devices. So in this sense, the Arduino project relies heavily
on its branding for its financial success . Other projects manufacture compatible
and cheaper boards, however people are loyal to the Arduino branded boards
because they associate quality and a certain image to the
final product.
1.2.2.1 By the Numbers
Year Units Sold
2005 200
2006 10 000
2010 120 00

8
2011 300 000
1.2.3 Competitors
Before Arduino, the largest players in the design/hobbyist market segment
were the PIC microcontroller family (made by Microchip) and the BASIC
Stamp (made by Parallax). Since the introduction of the Arduino, other large
companies have tried to enter the hobbyist market, including Texas Instruments
, and even Microsoft . However, the open-sourced tools
of the Arduino and the size of its community are large barriers for new
platforms to overcome.

1.2.4 Community
As the project is aimed at students and hobbyists who may not have any
formal electronics background, there are many excellent guides online covering
everything from making a light blink to creating a laser harp. The official forum
has almost 60 000 registered users, and along with helping users with their
projects, is extremely active in developing new libraries to extend the
functionality of the Arduino . The open-source share and share alike sentiment
is very strong, and the vast majority of users freely publish the code to their
projects.

1.3 PHYSICAL COMPUTING


Physical Computing is an approach to learn how humans communicate
through computers that starts by considering how humans express themselves
physically.

9
PLATFORM
HARDWARE

2.1 ARDUINO Board Layout

Figure 2 ARDUINO board layout

2.2 ARDUINO pin diagram

Figure 3 ARDUINO pin diagram

10
2.2.1 ATmega8(Microcontroller)

 16 MHz
 8 Kbyte Flash RAM(1K taken by the boot loader)
 1 Kbyte RAM(eg.for auto/local variables and stack)
 14 digital Input/Output Ports

Figure 4 ATmega8

2.2.2 Single chip USB to async. Serial data transfer interface

 USB 2.0 compatible


 Transmit and receive LED drive signals
 256 Byte receive,128 Byte transmit buffer
 Data transfer rate from 300bits/sec to 2 Mb/sec

11
2.2.3 EXTERNAL POWER

Figure 5 AC adapter can be used


Figure 6 ARDUINO can run off with USB or EXTERNAL power source

The power requirement for ARDUINO is 9 to


12V DC, 250mA or more,2.1mm plug, centre pin
positive.
The OFF-the shelf adapter
 must be a DC adapter (i.e. it has to put out
DC, not AC) Figure 7 An easier way to connect a battery

 should be between 9V and 12V DC


 must be rated for a minimum of 250mA current output, although you will
likely want something more like 500mA or 1A output, as it gives you the
current necessary to power a servo or twenty LEDs if you want to.
 must have a 2.1mm power plug on the Arduino end, and
 The plug must be "centre positive", that is, the middle pin of the plug has
to be the + connection.
Current rating: Since you'll probably be connecting other things to the
Arduino (LEDs, LCDs, servos) you should get an adapter that can supply at

12
least 500mA, or even 1000 mA (1 ampère). That way you can be sure you have
enough juice to make each component of the circuit function reliably.
The Arduino's on-board regulator can actually handle up to 20V or more, so you
can actually use an adapter that puts out 20V DC. The reasons you don't want to
do that are twofold: you'll lose most of that voltage in heat, which is terribly
inefficient. Secondly, the nice 9V pin on the Arduino board will actually be
putting out 20V or so, which could lead to potential disaster when you connect
something expensive to what you thought was the 9V pin. Our advice is to stick
with the 9V or 12V DC adapter.

2.2.4 ARDUINO flavors!!


There have been many revisions of the USB Arduino.some of them are
1. Arduino UNO:
This is the latest revision of the basic Arduino
USB board. It connects to the computer with a
standard USB cable and contains everything
else you need to program and use the board. It
can be extended with a variety of shields:
custom daughter-boards with specific features.
It is similar to the Duemilanove, but has a
different USB-to-serial chip the ATMega8U2,
and newly designed labeling to make inputs and outputs easier to identify.

2. Arduino Mega 2560:


A larger, more powerful Arduino
board. Has extra digital pins, PWM
pins, analog inputs, serial ports,
etc. The version of the Mega
released with the Uno, this version

13
features the Atmega2560, which has twice the memory, and uses
the ATMega 8U2 for USB-to-serial communication.

3. LilyPad Arduino:

A stripped-down, circular Arduino board designed for stitching into clothing


and other fabric/flexible applications. Needs an additional adapter to
communicate with a computer.

4. Arduino Extreme

The Arduino Extreme uses many more surface mount components than
previous USB Arduino boards and comes with female pin headers. It also
has RX and TX LEDs that indicate when data is being sent to or from the
board.

14
5. Arduino Mini 04

On this version of the Arduino Mini, two of the pins changed. The third pin
became reset (instead of ground) and fourth pin became ground (instead of
being unconnected). These boards are labelled "Mini 04".

Still there are ,Arduino Serial,Arduino Serial v2.0,Arduino Nano


3.0,Arduino Nano 2.x,Serverino(S3V3),Arduino Stamp 02,Mini USB
adapter 03,Mini USB Adapter,Arduino Bluetooth.

15
Figure 8 Different Flavours Of ARDUINO with their Configuration
2.2.5 Basic Terminologies in ARDUINO:
1.Analog to digital converter(ADC)
The process of Analog to digital conversion is shown in
figure.
The Arduino has 10 bits of Resolution when reading analog
signals.
2 power 10=1024 increments
Influence also by how fast you sample

2.Pulse width modulation (PWM)


The Arduino has 8bit of resolution,when outputting a signal using PWM.The
range of output voltage is from 0 to 5 Volts 2power 8=255 Increments .

16
2.3 LANGUAGE REFERENCES:
The Microcontroller on the board is programmed using the Arduino
programming language(based on wiring) and the arduino development
environment(based on processing).

2.3.1 Arduino Programming Language (APL) (based on


wiring)
The Arduino programming language is an implementation of Wiring, a
similar physical computing platform, which is based on the Processing
multimedia programming environment.
2.3.1.1 Wiring
Wiring is an open-source programming framework for microcontrollers.
Wiring allows writing cross-platform software to control devices attached to a
wide range of microcontroller boards to create all kinds of creative coding,
interactive objects, spaces or physical experiences. The framework is
thoughtfully created with designers and artists in mind to encourage a
community where beginners through experts from around the world share ideas,
knowledge and their collective experience. There are thousands of students,
artists, designers, researchers, and hobbyists who use Wiring for learning,
prototyping, and finished professional work production.
2.3.2 Arduino development environment (based on
processing)
2.3.2.1 Processing
Processing is an open source programming language and environment
for people who want to create images, animations, and interactions. Initially
developed to serve as a software sketchbook and to teach fundamentals of
computer programming within a visual context, Processing also has evolved
into a tool for generating finished professional work. Today, there are tens of

17
thousands of students, artists, designers, researchers, and hobbyists who use
Processing for learning, prototyping, and production.

2.3.3 Software
The software used by the arduino is Arduino IDE.

he Arduino IDE is a cross-platform application written in Java, and is derived


from the IDE for the Processing programming language and the Wiringproject.
It is designed to introduce programming to artists and other newcomers
unfamiliar with software development. It includes a code editor with features
such as syntax highlighting, brace matching, and automatic indentation, and is
also capable of compiling and uploading programs to the board with a single
click. There is typically no need to edit makefiles or run programs on
acommand-line interface. Although building on command-line is possible if
required with some third-party tools such as Ino.

The Arduino IDE comes with a C/C++ library called "Wiring" (from the project
of the same name), which makes many common input/output operations much
easier. Arduino programs are written in C/C++, although users only need define
two functions to make a runnable program:

 setup() – a function run once at the start of a program that can initialize
settings
 loop() – a function called repeatedly until the board powers off

18
Figure 9 A screenshot of the Arduino IDE showing the "Blink"program,a simple biginner program

A typical first program for a microcontroller simply blinks a LED on and off. In
the Arduino environment, the user might write a program like this:
#define LED_PIN 13

void setup () {
pinMode (LED_PIN, OUTPUT); // enable pin 13 for
digital output
}

void loop () {
digitalWrite (LED_PIN, HIGH); // turn on the LED
delay (1000); // wait one second (1000
milliseconds)
digitalWrite (LED_PIN, LOW); // turn off the LED

19
delay (1000); // wait one second
}

For the above code to work correctly, the positive side of the LED must be
connected to pin 13 and the negative side of the LED must be connected to
ground. The above code would not be seen by a standard C++ compiler as a
valid program, so when the user clicks the "Upload to I/O board" button in the
IDE, a copy of the code is written to a temporary file with an extra include
header at the top and a very simple main() function at the bottom, to make it a
valid C++ program.

The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs,
and uses avrdude to upload programs to the board.

For educational purposes there is third party graphical development


environment called Minibloq available under a different open source license.

2.3.3.1 language reference


Arduino programs can be divided in three main
parts: structure, values (variables and constants), and functions.

Available datatypes in ARDUINO IDE are

•void

•boolean

•char ( 0 – 255)

•byte - 8 bit data ( 0 – 255)

•int - 16-bit data (32,767 - -32,768)

•long – 32 bit data (2,147,483,647 to -2,147,483,648)

•float

20
•double

•string - char array

•String - object

•array

Arithmetic operators
Arithmetic operators include addition, subtraction, multiplication and
division.For math that requires fractions, you can use float variables, if you can
bear large size and slow computation speeds in your microcontroller.
e.g. ,
y = y + 3;
x = x – 7;
i = j * 6;
r = r / 5;

Comparison operators
Comparisons of one variable or constant against another are often used in if
statements to test if a specified condition is true.
e.g. ,
x == y // x is equal to y
x!= y // x is not equal to y
x < y // x is less than y
x > y // x is greater than y
x <= y // x is less than or equal to y
x >= y // x is greater than or equal to y

Logical operators
Logical operators are usually a way to logically combine two expressions and
return a TRUE or FALSE depending on the operator.

21
There are three logical operators, AND, OR, and NOT.
e.g.,
Logical AND:
if (x > 0 && x < 5) // true only if both expressions are true

Logical OR:
if (x > 0 || y > 0) // true if either expression is true

Logical NOT:
if (!x > 0) // true only if expression

TRUE/FALSE
These are Boolean constants that define logic levels of the arduino.
FALSE is easily defined as 0 (zero)
TRUE is often defined as 1, but can also be anything else except zero. So in a
Boolean sense, -1, 2, and -200 are all also defined as TRUE.
e.g. ,
if (abcd== TRUE);
{
DoSomethingNice;
}
else
{
DoSomethingHorrible;
}

HIGH/LOW
These constants define pin levels as HIGH or LOW and are used when
reading or writing to digital pins.
HIGH is defined as logic level 1, ON, or 5 volts
LOW is logic level 0, OFF, or 0 volts.

22
e.g. ,
digitalWrite(13, HIGH);
INPUT/OUTPUT
These constants define pin levels as HIGH or LOW and are used when
reading or writing to digital pins.
HIGH is defined as logic level 1, ON, or 5 volts

LOW is logic level 0, OFF, or 0 volts .


e.g. ,
pinMode(13, OUTPUT);

2.3.3.2 Arduino/processing language Comparision


The Arduino language (based on Wiring) is implemented in C/C++, and
therefore has some differences from the Processing language, which is based on
Java.

Figure 10 Comparision between Arduino and Processing language

23
INTERFACING OF ARDUINO
Different components /modules are interfaced with arduino for different uses.

Some of the components that are generally interfaced with arduino are :-

1. LED
2. SWITCH
3. POTENTIOMATER
4. TEMPRATURE SENSORS
5. PIR / IR SENSORS
6. 7 SEGMENT DISPLAY
7. LCD
8. RELAY

INTERFACING OF LED
Led is a most commonly used component in electronics and
communication, it is a light emmiting diode used as an light source.
Positive of led is connected to a resistor as it requires very less voltage
and arduino provides 5 v.
The resistor is then connected to the digital pin of arduino and the
negative of led is given to grnd of arduino.

24
INTERFACING OF SWITCH
Switch is used to give user a freedom of controlling an appliance as it gives an
option of weather the appliance that is used will be closed or in open condition.
Switch has 3 terminals positive is given a 5 v power supply and negative is
given to grnd of arduino.
The third and middle terminal is given to digital pin of arduino as an input.
When the switch is pressed HIGH is send to arduino digital pin and in off
condition LOW is send.
CODE:-

int inPin = 2; // the number of the input pin


int outPin = 13; // the number of the output pin

int state = HIGH; // the current state of the output pin


int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin

void setup()
{
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
}

void loop()
{
reading = digitalRead(inPin);

if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;

time = millis();
}

digitalWrite(outPin, state);

previous = reading;
}

25
INTERFACING OF POTENTIOMETER

A potentiometer is a simple knob that provides a variable resistance, which we


can read into the Arduino board as an analog value. In this example, that value
controls the rate at which an LED blinks.

We connect three wires to the Arduino board. The first goes to ground from
one of the outer pins of the potentiometer. The second goes from 5 volts to
the other outer pin of the potentiometer. The third goes from analog input 2
to the middle pin of the potentiometer.

By turning the shaft of the potentiometer, we change the amount of resistence


on either side of the wiper which is connected to the center pin of the
potentiometer. This changes the relative "closeness" of that pin to 5 volts and
ground, giving us a different analog input. When the shaft is turned all the way
in one direction, there are 0 volts going to the pin, and we read 0. When the
shaft is turned all the way in the other direction, there are 5 volts going to the
pin and we read 1023. In between, analogRead() returns a number between 0
and 1023 that is proportional to the amount of voltage being applied to the
pin.

26
Code

/* Analog Read to LED

int potPin = 2; // select the input pin for the potentiometer


int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}

void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}

27
INTERFACING OF TEMPERATURE SENSOR

These sensors have little chips in them and while they're not that delicate, they
do need to be handled properly. Be careful of static electricity when handling
them and make sure the power supply is connected up correctly and is
between 2.7 and 5.5V DC - so don't try to use a 9V battery!

They come in a "TO-92" package which means the chip is housed in a plastic
hemi-cylinder with three legs. The legs can be bent easily to allow the sensor
to be plugged into a breadboard. You can also solder to the pins to connect
long wires. If you need to waterproof the sensor, you can see below for an
Instructable for how to make an excellent case.

Unlike the FSR or photocell sensors we have looked at, the TMP36 and friends
doesn't act like a resistor. Because of that, there is really only one way to read
the temperature value from the sensor, and that is plugging the output pin
directly into an Analog (ADC) input.

Remember that you can use anywhere between 2.7V and 5.5V as the power
supply. For this example I'm showing it with a 5V supply but note that you can
use this with a 3.3v supply just as easily. No matter what supply you use, the
analog voltage reading will range from about 0V (ground) to about 1.75V.

28
If you're using a 5V Arduino, and connecting the sensor directly into an Analog
pin, you can use these formulas to turn the 10-bit analog reading into a
temperature:
Voltage at pin in milliVolts = (reading from ADC) * (5000/1024)
This formula converts the number 0-1023 from the ADC into 0-5000mV (= 5V).

CODE:-

int sensorPin = 0;

void setup()

Serial.begin(9600); //Start the serial connection with the computer

//to view the result open the serial monitor

void loop() // run over and over again

//getting the voltage reading from the temperature sensor

int reading = analogRead(sensorPin);

float voltage = reading * 5.0;

voltage /= 1024.0;

Serial.print(voltage);

Serial.println(" volts");

float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per


degree with 500 mV offset

Serial.print(temperatureC); Serial.println(" degrees C");

float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;

Serial.print(temperatureF);

29
Serial.println(" degrees F");

delay(1000);

30
INTERFACING OF PIR/IR SENSOR

PIR sensors allow you to sense motion, almost always used to detect whether a
human has moved in or out of the sensors range. They are small, inexpensive,
low-power, easy to use and don't wear out. For that reason they are commonly
found in appliances and gadgets used in homes or businesses. They are often
referred to as PIR, "Passive Infrared", "Pyroelectric", or "IR motion" sensors.

PIRs are basically made of a pyroelectric sensor (which you can see above as
the round metal can with a rectangular crystal in the center), which can detect
levels of infrared radiation. Everything emits some low level radiation, and the
hotter something is, the more radiation is emitted. The sensor in a motion
detector is actually split in two halves. The reason for that is that we are
looking to detect motion (change) not average IR levels. The two halves are
wired up so that they cancel each other out. If one half sees more or less IR
radiation than the other, the output will swing high or low.

Most PIR modules have a 3-pin connection at the side or bottom. The pinout
may vary between modules so triple-check the pinout! It's often silkscreened
on right next to the connection (at least, ours is!) One pin will be ground,
another will be signal and the final one will be power. Power is usually 3-5VDC
input but may be as high as 12V. Sometimes larger modules don't have direct
output and instead just operate a relay in which case there is ground, power
and the two switch connections.
The output of some relays may be 'open collector' - that means it requires a
pullup resistor. If you're not getting a variable output be sure to try attaching a
10K pullup between the signal and power pins.
An easy way of prototyping with PIR sensors is to connect it to a breadboard
since the connection port is 0.1" spacing. Some PIRs come with header on
them already, the one's from adafruit have a straight 3-pin header on them for
connecting a cable

For our PIR's the red cable is + voltage power, black cable is - ground power
and yellow is the signal out. Just make sure you plug the cable in as shown
above! If you get it backwards you won't damage the PIR but it won't work.

31
CODE:-
1. int ledPin = 13; // choose the pin for the LED
2. int inputPin = 2; // choose the input pin (for PIR sensor)
3. int pirState = LOW; // we start, assuming no motion detected
4. int val = 0; // variable for reading the pin status
5.
6. void setup() {
7. pinMode(ledPin, OUTPUT); // declare LED as output
8. pinMode(inputPin, INPUT); // declare sensor as input
9.
10. Serial.begin(9600);
11.}
12.
13.void loop(){
14. val = digitalRead(inputPin); // read input value
15. if (val == HIGH) { // check if the input is HIGH
16. digitalWrite(ledPin, HIGH); // turn LED ON
17. if (pirState == LOW) {
18. // we have just turned on
19. Serial.println("Motion detected!");
20. // We only want to print on the output change, not state
21. pirState = HIGH; }
22. else {
23. digitalWrite(ledPin, LOW); // turn LED OFF
24. if (pirState == HIGH){
25. // we have just turned of
26. Serial.println("Motion ended!");
27. // We only want to print on the output change, not state
28. pirState = LOW;
29. } }

32
INTERFACING OF 7 SEGMENT DISPLAY

Far left: the circuit that we are going to build shown as a schematic; where A -
G and DP connect to sequential output ports on the Arduino board. Each
segment of the display has a resistor in series to lower the current through the
LED's. Note that although it may seem quicker to connect one resistor to the
common pin, this would alter the brightness of the LED's depending how many
segments were turned on.
Left: the graphical view of a 7 segment display showing one common
arrangement for internal wiring and pin arrangement. This shows a common
anode unit so the two center common pins are connected to 5V. For common
cathode this would be GND.
At this point, make a note of the starting output, as you will need it later when
uploading the program.
For this example, the display was common anode, so therefore COMMON is
connected to +5V. Further, we switch OFF the A-G pins to light up a segment. If
the display were common cathode, we would reverse this.
At the bottom of the article is a photo of the circuit running on my prototype
board. We also provide a library for driving more than one display.

33
CODE:-
// set this to the first pin where wiring starts.
int ledStart = 30;

// set to true if the common pin is HIGH, false otherwise


boolean commonHigh = true;

void setup() {
// Enable all A-G and DP and outputs,
// set them to OFF (if common is high, then 1 is off).
for(int i=0;i<8;++i) {
pinMode(ledStart + i, OUTPUT);
digitalWrite(ledStart + i, commonHigh?1:0);
}
}

void loop() {
// write the number 0 - F (hex)
// onto the display each half second
for(int i=0;i<16;i++) {
writeDigitToDisplay(i);
delay(500);
}
}

// Now we define the bits that are on and off


// for each segment, These are used in the

34
// function below to turn the right bits on.
int dig[16] = {
// bits 6543210
// digits abcdefg
0b1111110,//0
0b0110000,//1
0b1101101,//2
0b1111001,//3
0b0110011,//4
0b1011011,//5
0b1011111,//6
0b1110000,//7
0b1111111,//8
0b1111011,//9
0b1110111,//a
0b0011111,//b
0b1001110,//c
0b0111101,//d
0b1001111,//e
0b1000111 //f
};

void writeDigitToDisplay(int digit) {


// iterate through each bit
for(int i=0;i<7;++i) {
// isolate the current bit in the loop.
int currentBit = (1<<(6-i));
// and compare with that bit in the digit
// definition above.

35
int bitOn = (currentBit&dig[digit])!=0;

// if common is high we invert the logic, as 0 is on.


if(commonHigh) {
bitOn = !bitOn;
}

// and lastly set the bit


digitalWrite(ledStart+i, bitOn);
}
}

Fig- seven segment display.

36
INTERFACING OF LCD
LCD modules form a very important part in many arduino based embedded
system designs. So the knowledge on interfacing LCD to arduino is very
essential in designing embedded systems. This article is about interfacing a
16×2 LCD to Arduino. JHD162A is the LCD module used here. JHD162A is a
16×2 LCD module based on the HD44780 driver from Hitachi. The JHD162A has
16 pins and can be operated in 4-bit mode or 8-bit mode. Here we are using
the LCD module in 4-bit mode. First, I will show you how to display plain text
messages on the LCD module using arduino and then few useful projects using
LCD and arduino. Before going in to the details of the project, let’s have a look
at the JHD162A LCD module.

JHD162A LCD module 16×2.

The JHD162A has 16 pins and can be operated in 4-bit mode or 8-bit mode.
Here we are using the LCD module in 4-bit mode. Before going in to the details
of the project, let’s have a look at the JHD162A LCD module.The schematic of a
JHD162A LCD module is given below.

The name and functions of each pin of the JHD162A LCD module is given
below.
Pin1(Vss):Ground pin of the LCD module.
Pin2(Vcc):+5V supply is given to this pin
Pin3(VEE):Contrast adjustment pin. This is done by connecting the ends of a
10K potentimeter to +5V and ground and then connecting the slider pin to the
VEE pin. The voltage at the VEE pin defines the contrast. The normal setting is
between 0.4 and 0.9V.
Pin4(RS):Register select pin.The JHD162A has two registers namely command
register and data register. Logic HIGH at RS pin selects data register and logic
LOW at RS pin will select command register. If we make the RS pin HIGH and
put a data on the data lines (DB0 to DB7) it will be recognized as a data. If we
make the RS pin LOW and put a data on the data lines, then it will be taken as a
command.

37
Pin5(R/W): Read/Write modes. This pin is used for selecting between read and
write modes. Logic HIGH at this pin activates read mode and logic LOW at this
pin activates write mode.
Pin6(E): This pin is meant for enabling the LCD module. A HIGH to LOW signal
at this pin will enable the module.
Pin7(DB0) to Pin14(DB7): These are data pins. The commands and data are
put on these pins.
Pin15(LED+): Anode of the back light LED. When operated on 5V, a 560 ohm
resistor should be connected in series to this pin. In arduino based projects the
back light LED can be powered from the 3.3V source on the arduino board.
Pin16(LED-): Cathode of the back light LED.
For knowing more about LCD module JHD162A and it interfacing, read this
article: Interfacing 16×2 LCD and 8051 microcontroller. The circuit diagram of
interfacing LCD to arduino for displaying a text message is shown below.

Circuit diagram.

RS pin of the LCD module is connected to digital pin 12 of the arduino. R/W pin
of the LCD is grounded. Enable pin of the LCD module is connected to digital
pin 11 of the arduino. In this project, the LCD module and arduino are
interfaced in the 4-bit mode. That means only four of the digital input lines(

38
DB4 to DB7 of the LCD are used). This method is very simple, requires less
connections and you can almost utilize the full potential of the LCD module.
Digital lines DB4, DB5, DB6 and DB7 are interfaced to digital pins 5, 4, 3 and 2
of the Arduino. The 10K potentiometer is used for adjusting the contrast of the
display. 560 ohm resistor R1 limits the current through the back light LED. The
arduino can be powered through the external power jack provided on the
board. +5V required in some other parts of the circuit can be tapped from the
5V source on the arduino board. The arduino can be also powered from the PC
through the USB port. The full program for interfacing LCD to arduino is shown
below.

CODE:-

#include<LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // sets the interfacing pins

void setup()

lcd.begin(16, 2); // initializes the 16x2 LCD

}void loop()

{ lcd.setCursor(0,0); //sets the cursor at row 0 column 0

lcd.print("16x2 LCD MODULE"); // prints 16x2 LCD MODULE

lcd.setCursor(2,1); //sets the cursor at row 1 column 2

lcd.print("HELLO WORLD"); // prints HELLO WORLD

39
INTERFACING OF RELAY
To connect the 4 Relay board to an Arduino is very easy and allows you to turn
on and off an wide range of devices, both AC and DC. The first to connections
are the ground and power pins, you need to connect the
Arduino +5v to the 4 Relay board VCC pin and the Arduino ground to the 4
Relay board GND pin. Then it’s a only a matter of just connecting the
communication pins, labeled IN1, IN2, IN3 and IN4, two 4 data pins
on the Arduino.

In the example code below I used Arduino pins 7, 8 , 9, 10. I avoid using Data
pins 0 and 1 as they are used by the Arduino for serial communication and can
cause problems when uploading code to the Arduino.

The default state of the relay when the power is off for COMM (power) to be
connected to NC (normally closed),
this is the equivalent of setting the 4 Relay boards IN pin to HIGH (has +5v sent
to it) It is a safety feature to not
use the NC connector in-case you Arduino looses power it will automatically
turns off all the devices connected
to the relay.

When you have something connected to the relays NO (Normally Open)


connector and you set the corresponding IN pin to LOW (0v), power will flow in
from the COMM connector and out of the NO connector powering your
device..

40
CODE:-
1. int pinButton = 8;
2. int Relay = 2;
3. int stateRelay = LOW;
4. int stateButton;
5. int previous = LOW;
6. long time = 0;
7. long debounce = 500;
8.
9. void setup() {
10. pinMode(pinButton, INPUT);
11. pinMode(Relay, OUTPUT);
12. }
13.
14. void loop() {
15. stateButton = digitalRead(pinButton);
16. if(stateButton == HIGH && previous == LOW && millis() -
time > debounce) {
17. if(stateRelay == HIGH){
18. stateRelay = LOW;
19. } else {
20. stateRelay = HIGH;
21. }
22. time = millis();
23. }
24. digitalWrite(Relay, stateRelay);
25. previous == stateButton;

41
APPLICATIONS OF ARDUINO
Arduino was basically designes to make the process of using electronics in
multidisciplinary projects more accessible.It is intended for
artists,designers,hobbyists,and anyone interested in creating interactive objects
or environments.Arduino can sense the environment by receiving input from a
variety of sensors and can affect its surroundings by controlling
lights,motors,and other actuators.because of these features,arduino finds
extensive application in various fields.Arduino projects can be stand-alone or
they can communicate with software running on a computer.

Arduino received an Honarary Mention in Digital Communication section of


the 2006 Ars Electronica Prix

Arduino is used by all class of people in a different way.some students use it


in their projects,some using arduino for fun,some went out to become
entreupreuners.This only shows how useful is this tiny device.

Figure 11 ARDUINO FEVER

ARDUINO is spreading rapidly across the globe. Arduino is actually an open


source hardware project that can be pro grammed to read temperatures, control a
motor, and sense touch.

42
the Arduino is both a cute, blue micro controller platform that fits nicely in the
palm of your hand and an expanding community of developers who support it,
distributed across two dozen coun tries, four continents, and counting.

The Arduino board is for anyone who wants to build a basic level of intelligence
into an object. Once programmed, it can read sensors, make simple decisions,
and control myriad devices in the real world. Using it is a snap: first, hook up a
few sensors and output devices to the Arduino, then program it using the free
developer’s software. Next, debug your code and disconnect the
Arduino.Then,the little blue Arduino becomes a standalone computer.

The original intention of the Arduino project was to see what would happen if
community support were substituted for the corporate support that is usually
required for electronics development. The first developers — Massimo Banzi,
David Cuartielles, David Mellis, and Nicholas Zambetti — ran a series of
workshops on assembling the Arduino, giving away the board to stimulate
development.

Thousands of projects have been done worldwide using this tiny little
device.some of which to mention are:

 Simple room temperature readout


 Interactive real-time auditory feedback system
 GPS receiver Module
 Ultrasonic Sensor
 Infrared detectors
 SONAR
 Various sensor projects like
 Keypad security code
 Sensor tube for heart monitor
 Pulse rate monitor

43
 Various light projects like
 Multicolor light display
 Seven-segment LED display
 Double seven-segment LED dice
 LED array
 LCD module

 Various sound projects like


 Oscilloscope
 Light harp
 VU meter
 Various power projects like
 LCD Thermostat
 Computer controlled fan
 The hypnotizer
 Miscellaneous Projects like
 Lie detector
 Magnetic door lock
 Infrared remote
 Lilypad binary clock

Just to name a few….as the trademark goes,there are nearly infinite


possible projects using this tiny device,which we still yet to discover

Some of the major applications are 3D printers,whos founder went out


to become an euntreuprenuer,and major pride came to
ARDUINO,when giant firm GOOGLE’s most ambitious
ANDROID,deployed ARDUINO in its new venture “ANDROID
OPEN ACCESSORY DEVELOPMENT KIT”.which allows external

44
USB hardware to interact with an Android-powered device in a
special accessory mode.ANDROID executive announced this in
annual GOOGLE IO meet conference 2011.ANDROID calls that
device made of arduino as ADK(Android development kit).

Arduino also has won annual “2012 INTERACTION AWARD”


sponsored by GOOGLE,for its extensive applications in various fields.

3.1 Why Arduino is popular?

Here are five reasons why the Arduino is more popular than beagleboard:

 Starter Projects: Editing and rewriting is often easier than writing from
scratch. It’s the same with electronics. It’s easier to mod an idea than start
with a blank slate.That’s where the BeagleBoard falls short. “It has
virtually no example application that you can just copy and hack to learn
from,” says Massimo Banzi, one of the co-founders of the Arduino
project. It’s a chicken-and-egg problem for the BeagleBoard. Unless there
are more example codes out there, it is difficult to draw in the audience.
And without the audience it is challenging to get enough sample projects
into the community.

 Cost and Durability: At $30 a piece, an Arduino is an inexpensive


investment for someone who wants to try it out. “It’s the price of a few
sandwiches,” says Torrone. Compare that to the BeagleBoard-xM, which
costs $180. One reason why the Arduino is so cheap is because it is easy
to clone. The microcontroller is completely open source so the
“components are all commodity,” says Torrone. With the BeagleBoard,
hobbyists don’t have the same amount of freedom. They have to work

45
closely with Texas Instruments or its partners, says Torrone. Arduino is
also very resilient. Drop it, smash it and it still stays alive. Add to that its
low-power requirement, and the product becomes a must-have for
DIYers. An Arduino can run on a 9V-battery for days. “The BeagleBoard
is fast and powerful but that also means lots of energy is needed, which
makes it difficult for simple projects,” says Torrone.

 A Thriving Community: Arduino’s popularity means it’s easy to get


started. Companies such as Adafruit, SparkFun and Liquidware not only
sell chips, but they also host blogs that suggest ideas on how to use your
Arduino while providing extensive project plans to guide you in
completing your creations. Will Chellman, a student who has played with
Arduino for years, says he’s now experimenting with the BeagleBoard.
But finding documentation and information to work off is not easy, he
says. The lack of well-documented projects done with the BeagleBoard
can be intimidating to new users as well, says Banzi. “There’s lots of of
interesting stuff (about the BeagleBoard) but it is very technical,”
he wrote in a comment recently on Gadget Lab in response to the launch
of BeagleBoard-xM. Banzi says BeagleBoard documentation is also
scattered and fragmented. “Parts of it have aged and you spend quite a bit
of time jumping from wikis to mailing list to track which specific bit of
documentation applies to your board, bootloader etc.,” he says.

 Maturity is the key: Arduino has had a head start on the BeagleBoard.
By October 2008, about 50,000 Arduino boards had already been
shipped. That year, the first BeagleBoards started making their way into
the hands of hardware enthusiasts. The BeagleBoard is just two years old.
Since it hasn’t been around long enough, there’s not enough people
building apps based on it,” says Chellman. That’s not to say that

46
BeagleBoard isn’t catching up. Earlier this month, we showed five
projects ranging from a videowall to the iPad of ham radios that use the
BeagleBoard. There’s also a build-your-own tablet kit that is based off
the BeagleBoard.

 Simple is attractive: With its single-board computer configuration, 1-


GHz processing power and the choice of accessories, the BeagleBoard is
a creative engineer’s dream come true. But the same reasons make it
intimidating to those who want to geek out on a DIY project but don’t
have the technical know-how. Arduino users point out that it is simple to
connect external sensors to the board, and the example codes out there
make it easy to get started quickly. Arduino is a simple system designed
for creative people with little or “no prior knowledge of electronics,” says
Banzi. “It’s cheap and open source with lots of documentation written in
a not too technical language. Above all, it has a very welcoming attitude
towards beginners and tries not to scare them too much.”

3.2 Conclusion and future scope

Over the years,Arduino has went out to become a huge success and a
common name among students.With google deploying it,people’s
imagination has went out to much higher level than before.A developer in
the annual GOOGLE IO conference said “when Arduino and Android
coming together,this really proves “INFINITY EXISTS” in the future”.I
think a study on arduino and practical experiments on arduino must be added
for UG courses of engineering,to help students to leverage their talents,and
imagination.

47
PROJECT DESCRIPTION

AIM :- To make a SMART HOME AUTOMATION using


ARDUINO controlled by ANDROID platform.

OVERVIEW :-
As this world is becoming smart day by day why not to make our living
spaces smart.

In this project i have tried to make our homes smart by making them to work
on your commands by using mobile phones having android platform.

Whenever a person gives a command using a phone a specific task is


performed like switching on a lamp or opening a door automatically without
physically contact.

There are many people who are specially able (physically), too old, not well
enough to walk to a switch to make an appliance to switch on or to open a
door this home automation can prove to be a great help for these people.

48
PROJECT DESCRIPTION :-
Smart home automation is a project to make our life smarter and easier
by providing us a way to control our basic home tasks automatic.

It uses an android application that is used to give commands (voice) to the


microcontroller with help of Bluetooth technology.

HC-05- wireless Bluetooth serial RF 5V Transeiver Module is used to


communicate between the smart phone and the microcontroller which in this
case is ATMEGA 328 on ARDUINO UNO.

As the commands are given by user through phone the android application
send the command to microcontroller using the Bluetooth module. The
microcontroller ( arduino) takes them as input and starts processing them as
per the defined code.

Microcontroller is connected to a 5V -2Channel board relay module which is


connected to light or motors for opening of doors, the number of appliances to
be controlled can be increased using higher a relay with higher number of
channels.

According to the commands given by the user that are predefined in


the source code of the project, different outputs are controlled like
switching on a light bulb or opening a door.
The arduino is given power by using a 5V/9V adapter or a 9V battery and the
appliances to be controlled are powered as per there specifications like a lamp
needs AC voltage.

** This projects needs AC which is very high voltage and hence during
installing it should be done very carefully and while working on relay utmost
attention is required.

49
BLOCK DIAGRAM:-

50
FLOW CHART

51
COMPONENTS USED:-
 Android based smart phone.

 HC-05 serial wireless Bluetooth module.

 Microcontroller (ARDUINO)

 5V-2CHANNEL board relay module

52
 Connecting wires
 Appliances to be controlled

CIRCUIT DIAGRAM:-

53
SNAPSHOTS

54
BIBLIOGRAPHY

1. ELECTRONIC RESOURCES

1.1. http://www.arduino.cc -Arduino Official webpage

1.2. http://en.wikipedia.org/wiki/Arduino -wikipedia

1.3. Jonathan Oxer,Hugh Blemings “Practical Arduino-cool projects for open


source hardware”

1.4. http://www.arduino.cc/playground/Projects/ArduinoUsers

1.5.http://www.arduinothedocumentary.org

1.6.http://www.google.com

1.7.http://www.accessories.android.com

1.8. Material provided by techies institute Amritsar

2.BOOKS AND JOURNELS


2.1. Embedded systems

2.2 Techies tutorial book.

55
56

S-ar putea să vă placă și