Arduino

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

1.

Arduino

Thanks to its simple and accessible user experience,


Arduino has been used in thousands of different projects
and applications. The Arduino software is easy-to-use for
beginners, yet flexible enough for advanced users. It runs
on Mac, Windows, and Linux. Teachers and students use
it to build low cost scientific instruments, to prove
chemistry and physics principles, or to get started with
programming and robotics. Designers and architects build
interactive prototypes, musicians and artists use it for installations and to experiment with
new musical instruments. Makers, of course, use it to build many of the projects exhibited at
the Maker Faire, for example. Arduino is a key tool to learn new things.

Arduino also simplifies the process of working with microcontrollers, but it offers some
advantage for teachers, students, and interested amateurs over other systems:

Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller


platforms. The least expensive version of the Arduino module can be assembled by hand, and
even the pre-assembled Arduino modules cost less than $50

Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux
operating systems. Most microcontroller systems are limited to Windows.

Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for
beginners, yet flexible enough for advanced users to take advantage of as well. For teachers,
it's conveniently based on the Processing programming environment, so students learning to
program in that environment will be familiar with how the Arduino IDE works.

Open source and extensible software - The Arduino software is published as open source
tools, available for extension by experienced programmers. The language can be expanded
through C++ libraries, and people wanting to understand the technical details can make the
leap from Arduino to the AVR C programming language on which it's based. Similarly, you
can add AVR-C code directly into your Arduino programs if you want to.

Open source and extensible hardware.

1
2. 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 andcommunication with the world it does, is what is governed by
what

instructions we give tothe 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 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.

2
3. Hardware

3.1) Arduino Board Layout

3.2) Arduino Pin Diagram

Flash RAM (1K taken by the boot loader)

1Kbyte RAM (eg.for auto/local variables and stack)

14 digital Input/output Ports

3
3.3) FTDI

Single chip USB to async. Serial data transfer interface

Future Technology Devices International,


commonly known by its abbreviation FTDI,
is a Scottish privately held semiconductor
device company, specializing in Universal
Serial Bus (USB) technology.

It develops, manufactures, and supports


devices and their related software drivers for
converting RS-232 or TTL serial
transmissions to USB signals, in order to allow support for legacy devices with modern
computers.

FTDI provides application-specific integrated circuit (ASIC) design services. They also
provide consultancy services for product design, specifically in the realm of electronic
devices.

 USB 2.0 compatible

 Transmit and receive LED frive signals


 256 Byte receive,128 Byte transmit buffer
 Data transfer rate from 300bits/sec to 2 Mb/sec

3.4) External power


External power can be given by
either the AC to DC adapter or the
serial com cable/USB connector as
shown below.

Note: For higher current applications (>30mA), never use the com port!!

4
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)
 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 "center 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 least 500mA, or even 1000 mA (1 ampere). 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.
Example: Arduino Uno powered by a 9V
battery

5
4. Flavours of Arduino
There have been many revisions of the USB
Arduino. Some of them are

4.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.

4.2)ArduinoMega 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 features the
Atmega2560, which has twice the
memory, and uses the ATMega 8U2 for USB-to-serial communication.

4.3)Arduino Duemilanove:
The Duemilanove automatically selects the
appropriate power supply (USB or external power),
eliminating the need for the power selection jumper
found on previous boards. It also adds an easiest to
cut trace for disabling the auto-reset, along with a
solder jumper for re-enabling it.

6
4.4)Arduino Fio:
An Arduino intended for use as a wireless node. Has a header
for an XBee radio, a connector for a LiPobattery, and a battery
chargingcircuit.

4.5)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.6) Arduino Diecimila:

The main change in the Arduino Diecimila is that it can be reset from the computer, without
the need to physically
press the reset button on
the board. The
Diecimila uses a low
dropout voltage
regulator which lowers
the board's power
consumption when
powered by an external
supply (AC/DC adapter or battery). A resettable polyfuse protects your computer's USB ports
from shorts and surges. It also provides pin headers for the reset line and for 3.3V. There is a
built-in LED on pin 13. Some blue Diecimila boards say "Prototype - Limited Edition" but
are in fact fully-tested production boards (the actual prototypes are red).

7
4.7)Lilypad Arduino 03

This revision has a 6-pin programming header that's compatible with FTDI USB cables and
the Sparkfun FTDI Basic Breakout. It adds support for automatic reset, allowing sketches to
be uploaded without pressing the reset button on the board. The header is surface mounted,
meaning that the board has no pokey bits sticking out the back.

4.8)Arduino Nano

Arduino Nano is a small complete chip board


based on ATmega 328 (v3.0) or Atmega 168
(v2.0). Every Arduino has the same functionality
and the same features except the number of pins
and size. One of the major flaws of this board is
that it doesn't have any power jack. So, you can't
supply power from any external power source like
battery. Apart from this, more or less this board is quite similar to any Arduino board.

The pros of this board are:Tiny size (or, compact) is one the major advantages of this board
and bread-board friendly.

But, the cons are:There is no direct power-source jack. So, you use any power source.But, the
preceding statement is not quite true. Since, it's a low voltage board you can use a power
source using the Vin Pin, but you need to take a few precautions. Otherwise it will burn the
board.More or less, it is equivalent to an Arduino UNO.

4.9) Arduino Pro mini


Smallest member of the Arduino family. This board is
available in two variants 3.3v/8MHz and 5v/16MHz, working
onATmega 328.

The only difference between pro mini and Nano is, that it

8
doesn’t have a USB to serial interface and voltage regulator (3.3v in 5v version).

It is basically designed to be used in the places where size is the topmost priority and
permanent installation.

Dimensions: 0.7x1.3" (18x33mm)

Features:

 0.8mm Thin PCB


 USB connection off board
 Weighs less than 2 grams!
 Supports auto-reset
 3.3V regulator
 Max 150mA output
 Over current protected
 DC input 3.3V up to 12V
 On board Power and Status LEDs
 Analog Pins: 8
 Digital I/O: 14

9
5. Basic Terminologies

5.1) Analog to Digital(ADC)


The process of Analog to digital conversion is shown
in figure.The Arduino has 10 bits of Resolution when
reading analog signals. 210=1024 increments.Influence
also by how fast you sample.

Here,

Fig.1 shows an analog graph, which can be readings of


any sensor for ex: LDR, POT, ultrasonic sensor.

These readings are fed in the ADC pins of Arduino


board, which is named as Ax, where x is a number, for
ex: A0, A1, A2 and so on.

In Fig.2, the analog values change into resolution of 210


in digital form.

Now, these values can be used to control any digital


module, for ex: servo with help of potentiometer with the help of PWM (explained below).

ADC is the most widely used colour of Arduino.

5.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 in 28=255 increments. Average of on/off (digital signals to
make an average voltage), Duty cycle in 100% of 5Volts.

10
NOTE: PWM pins are output pins.

6 PWM pins in an Arduino UNO are located as

PWM signals can be used to control dc motors, servos, stepper motors, brightness of any led,
etc.

5.3) Sketch
This is the term used for a program.

5.4) Shield

This is a circuit board that can be plugged on top of an Arduino. Shields have a variety of
applications. For example, motor driver shields, LCD shields etc.

11
5.5 ) Processing Code
This is the programming environment used most often with Arduino. It can be downloaded
(free) from arduino.cc. It is a somewhat simplified version of the C programming language.

5.6) IDE (Integrated Development Environment)


This is the software application
that is run to provide the tools to
allow you to develop software
for the Arduino. It includes the
source code editor, build
automation, and debugger.

This is the screenshot of the


latest Arduino ide version 1.8.0.

Creating a new sketch renames it


automatically on the date of the
current day. In this figure, the
date is feb27.

The fundamental parts of a


sketch are

 void setup() – a function run


once at the start of a program that can initialize settings. All the digital pins to be used in
the sketch are first defined in this function.
 void loop() – a function called repeatedly until the board powers off. This is under a
continuous infinite loop.

The black screen below the sketch is the compiler, which comes alive once the program is
run by pressing the tick button in the leftmost side.

The button beside the compile button is the upload button which is an arrow directing to the
right. This burns the program to the board connected to the USB port. The board connected
can be changed by going in the ‘Tools’ option in the menu bar.

12
5 Basic Programming concepts
The Arduino works on basic C environment. But the header files are pre-included in writing a
program. The sketch contains only the most relevant part of the program/code.

6.1)functions
A function is a block of code that has a name and a block of statements that are executed
when the function is called. The functions void setup() and void loop() have already been
discussed and other built in functions will be discussed later. Custom functions can be written
to perform repetitive tasks and reduce clutter in a program. Functions are declared by first
declaring the function type. This is the type of value to be returned by the function such as
‘int’ for an integer type function. If no value is to be returned, then the function type will be
taken as void.

type functionName(parameters)

{ statements; }

6.2){} curly braces


Curly braces define the beginning and end of function block and statement blocks such as the
void loop() function and the for and if statements.

type function()

{ statements; }

6.3); semicolon
A semicolon must be used to end a statement and separate elements of the program. A
semicolon is also used to separate elements in a for loop.

int x = 13; // declares variable ‘x’ as integer 13

13
Forgetting this semicolon will result in compile error.

6.4)Variables
A variable is a way of naming and storing a numerical value for later use by the program. As
their namesake suggests, variables are numbers that can be continually changed as opposed to
constants whose value never changes. A variable needs to be declared and optionally
assigned to the value needing to be stored. The following code declares a variable called
inputVariable and then assigns it the value obtained on analog input pin 2:

intinputVariable = 0; // declares a variable and assigns a value 0 to it

inputVariable = analogRead(2); // set variable to the value of analog pin 2

6.5)byte
Byte stores an 8-bit numerical value without decimal points. They have a range of 0-255.

byte someVariable = 180;

6.6)int
Integers are the primary datatypefor storage of numbers without decimal points and store a
16-bit value with a range of 32,767 to -32,768.

intsomeVariable = 1500;

6.7)long
Extended size datatype for long integers, without decimal points, stored in a 32-bit value with
a range of 2,147,483,647 to -2,147,483,648.

long someVariable = 90000;

14
6.8)float
A datatype for floating-point numbers, or numbers that have a adecimal point. Floating-point
numbers have greater resolution than integers and are stored as a 32-bit value with a range of
3.4028235E+38 to -3.4028235E+38.

float someVariable = 3.14;

6.9)arrays
An array is a collection of values that are accessed with an index number. Any value in the
array may be called upon by calling the name of the array and the index number of the value.
Arrays are zero indexed, with the first value in the array beginning at the index number 0. An
array needs to be declared and optionally assigned values before they can be used.

intmyArray[]={value0, value1, value2… }

Likewise, it is possible to declare an array by declaring the array type and size and later assign values
to an index position.

intmyArray[5];

myArray[3]=10;

To retrieve a value from an array, assign a variable to the array and index position:

x=myArray[3];

Arrays are often used in for loops, where the increment counter is also used as the index position for
each array value. The following example uses an array to flicker an LED. Using a for loop, the
counter begins at 0, writes the value contained at index position 0 in the array flicker[], in this case
180, to the PWM pin 10, pauses for 200ms, then moves to the next index position :

intledPin = 10; // led on pin 10

byte flicker[]={180,30,255,200,10,90,150,60}; // array of 8 different values

void setup()

pinMode(ledPin, OUTPUT); // setting output pin

15
}

void loop()

for(inti=0;i<7;i++)

analogWrite(ledPin, flicker[i]); // write index value

delay(200); // pause for 200 milliseconds

6.10) arithmetic
Arithmetic operators include addition, subtraction , multiplication, and division. They return
the sum, difference, product, or quotient (respectively) of two operands.

y = y + 3; // addition

x = x – 7; // subtraction

i = j * 6; // multiplication

r = r / 5; // division

The operation is conducted using the data type of the operands, so, for example, 9/4 results in
2 instead of 2.25 since 9 and 4 are ints and are incapable of using decimal points. This also
means that the operation can overflow if the result is larger than what can be stored in the
data type.

If the operands are of different data type, the larger type is used for the calculation. For
example, if one of the numbers (operands) are of the type float and the other of type integer,
floating point math will be used for the calculation.

Choose variables sizes that are large enough to hold the largest results from your calculations.
Know at what point your variable will rollover and also what happens in the other direction

16
e.g. (0 - 1) OR (0 - - 32768). For math that requires fractions, use float variables, but be
aware of their drawbacks: large size and slow computation speeds.

Note: Use the cast operator e.g. (int)myFloat to convert one variable type to another on the
fly. For example, i = (int)3.6 will set i equal to 3.

6.11) Compound Assignments


Compound assignments combine an arithmetic operation with a variable assignment. These
are commonly found in for loops as described later. The most common compound
assignments include:

x++ // same as x = x+1, or increments x by 1

x-- // same as x = x-1, or decrements x by 1

x += y // same as x = x+y, or increments x by +y

x -= y // same as x = x-y, or decrements x by -y

x *= y // same as x = x * y, or multiplies x by y

x /= y // same as x = x / y, or divides x by y

Note: For example, x *= 3 would triple the old value of x and re-assign the resulting value to
x.

6.12) Comparison Operators


Comparisons of one variable or constant against another are often used in if statements to test
if a specified condition is true. In the examples found on the following pages, ?? is used to
indicate any of the following conditions:

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

17
x <= y // x is less than or equal to y

x >= y // x is greater than or equal to y

6.13) Logical Operators


Logical operators are usually a way to compare two expressions and return a TRUE or
FALSE depending on the operator. There are three logical operators, AND, OR, and NOT,
that are often used in if statements:

Logical AND:

if (x > 0 && x < 5 ) // true only if both the expressions are true

Logical OR:

if (x > 0 || x < 5 ) // true only if either expression is true

Logical NOT:

if (!x>0 ) // true only if the expression is false

6.14) Constants
The Arduino language has a few predefines values, which are called constants. They are used
to make the programs easier to read. Constants are classified in groups.

6.15) true/false
These are Boolean constants that define logic levels. FALSE is easily defined as 0 (zero)
while 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.

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

digitalWrite(13, HIGH); // pin 13 is given as 5 volts

6.17) INPUT / OUTPUT


Constants used with the pinMode() function to define the mode of a digital pin as either
INPUT or OUTPUT.

pinMode(13, OUTPUT); // pin assigned for output

6.18) if…. else


if… else allows for ‘either - or’ decisions to be made. For example, if you wanted to test a
digital input, and do one thing if the input went HIGH or instead do another thing if the input
was LOW, you would write that this way:

if(inputPin == HIGH)

{ doThingA; }

else

{ doThingB; }

else can also precede another if test, so that multiple, mutually exclusive test can be run at the
same time. It is even possible to have an unlimited number of these else branches. Remember
though, only one set of statements will be run depending on the condition tests:

if(inputPin< 500)

{ doThingA; }

else if(inputPin>= 1000)

{ doThingB; }

19
else

{ doThingC; }

Note: An if statement simply tests whether the condition inside the parenthesis is true or
false. This statement can be any valid C statement as in the first example, if(inputPin ==
HIGH). In this example, the if statement only checks to see if indeed the specified input is at
logic level high, or +5v.

6.19) for loop


The for statement is used to repeat a block of statements enclosed in curly braces a specified
number of times. An increment counter is often used to increment and terminate the loop.
These are three parts, separated by a semicolon (;) to the for loop header:

for(initialization; condition; expression)

{ doSomething; }

The initialization of a local variable, or increment counter, happens first and only once. Each
time through the loop, the following condition is tested. If the condition remains true, the
following statements and expression are executed and the condition is tested again. When the
condition becomes false, the loop ends.

The following example starts the integer i at 0, tests to see if i is still less than 20 and if true,
increments i by 1 and executes the enclosed statements:

for(inti=0; i<20; i++) // declares i, tests if less than 20, increments i by 1

digitalWrite(13, HIGH); // turns pin 13 on

delay(250); // pauses for ¼ second

digitalWrite(13, LOW); // turns pin 13 off

delay(250); // pauses for ¼ second

20
6.20)pinMode(pin, mode)
Used in void setup() to configure a specified pin to behave either as an INPUT or an
OUTPUT.

pinMode(pin, OUTPUT); // sets ‘pin’ to output

Arduino digital pins default to inputs, so they don’t need to be explicitly declared as inputs
with pinMode(). Pins configured as INPUT are said to be in a high impedance state.

There are also convenient 20Kohm pullup resistors built into the atmega chip that can be
accessed from software. These built-in pull up resistors are accessed in the following manner:

pinMode(pin, INPUT); // set ‘pin’ to input

digitalWrite(pin, HIGH); // turn on pullup resistors

Pullup resistors would normally be used for connecting inputs like switches. Notice in the
above example that it does not convert pin to an output, it is merely a method for activating
the internal pull-ups.

Pins configuredas OUTPUT are said to be in a low-impedance state and can provide 40 mA
(milliamps) of current to other devices/circuits. This is enough current to brightly light up an
LED (don’t forget the series resistor), but not enough current to run most relays, solenoids, or
motors.

Short circuits on Arduino pins and excessive current can damage or destroy the output pin, or
damage the entire Atmega chip. It is often a good idea to connect an OUTPUT pin to an
external device in series with a 470ohm or 1kohm resistor.

6.21)digitalRead(pin)
Reads the value from a specified digital pin with the result either HIGH or LOW. The pin can
be specified as either a variable or constant (0-13).

value = digitalRead(pin); // sets ‘value’ equal to the input pin

21
6.22)digitalWrite(pin, value)
Outputs either logic level HIGH or LOW at (turns on or off) a specified digital pin. The pin
can be specified as either a variable or constant (0 - 13).

digitalWrite(pin, HIGH);

6.23)analogRead(pin)
Reads the value from a specified analog pin with a 10-bit resolution. This function only
works on the analog in pins (0-5). The resulting integer values range from 0 to 1023.

value = analogRead(pin);

Note: Analog pins inlike as digital ones, do not need to be first declared as INPUT or
OUTPUT.

6.24)analogWrite(pin, value)
Writes a pseudo- analog value using hardware enabled pulse width modulation (PWM) to an
output pin marked PWM. On newer Arduinos with the ATmega168 chip, this function works
on pins 3,5,6,9,10, and 11. Older Arduinos with an ATmega8 only support pin 9,10and 11.
The values can be specified as a variable or constant with a value from 0-225.

analogWrite(pin, value);

A value of 0 generates a steady 0 volts output at the specified pin; a value of 255 generates a
steady 5 volts output at the specified pin. For values in between 0 and 255, the pin rapidly
alternates between 0 and 5 volts – the higher the value, the more often the pin is HIGH (5
volts). For example, a value of 64 will be 0 volts three quarters of the time, and 5 volts one
quarter of the time; a value of 128 will be at 0 half the time and 255 half the time; and a value
of 192 will be 0 volts, one quarter of the time and 5 volts three quarters of the time.

22
Because this is a hardware function, the pin will generate a steady wave after a call to
analogWrite in the background until the next call to analogWrite (or a call to digitalRead or
digitalWrite on the same pin).

Note: analog pins unlike digital ones, donot need to be first declared as INPUT nor
OUTPUT.

6.25) delay(ms)
Pauses your program for the amount of time as specified in milliseconds, where 1000 equals
1 second.

delay(1000); // waits for one second

6.26)millis()
Returns the number of milliseconds since the Arduino board began running the current
program as an unsigned long value.

value = millis(); // sets ‘value’ equal to millis()

Note: This number will overflow (reset back to zero), after approximately 9 hours.

23
6. First Program

7.1) Object:

Blinking the led pin till the switch is pressed

7.2) Schematic:

7.3) Sketch:
void setup()

intSw=2; //Switch connected on digitalinput


pin 2

intLedPin= 13; //led connected to pin 13 Schematic Diagram

pinMode(Sw,INPUT); //declaring input pin

digitalWrite(Sw,LOW); //writing initial condition to //pin 2

void loop()

if (digitalRead(Sw)==HIGH)

{ digitalWrite(LedPin,HIGH); //LED ON

delay(1000); //giving a delay of 1 second

digitalWrite(LedPin,LOW); // LED OFF

delay(1000); //giving a delay of 1 second

}}

24
7. Serial Communication
The Serial Communication is bit by bit data sending through the serial port. This is basically
done by the Tx and the Rx pins on the board. This mode of communication is used to send or
receive the data or for entering inputs and displaying ouputs on the screen via serial monitor
in the IDE.

8.1) Serial.begin(rate)
Opens serial port and sets the baud rate for serial data transmission. The typical baud rate for
communicating with the computer is 9600 although other speeds are supported.

void setup()

{ Serial.begin(9600); }

Note: When using serial communication, digital pins 0 (Rx) and 1 (Tx) cannot be used at the
same time

8.2) Serial.println(data)
Prints data to the serial port, followed by an automatic carriage return and line feed. This
command takes the same form as Serial.print(), but is easier for reading data on the serial
monitor.

Serial.println(analogValue); // sends the value of analogValue

8.3) Serial.available()
This is the function that fetches the data on the serial bus at the communication port. This is
used to read the data coming from the Arduino through the serial port.

if(Serial.available()==’1’) // checks if the data on the bus is logically equal to 1.

{ int a =100; } // assigning the value 100 to the variable a

25
8. Home Automation System

9.1) Object :
Controlling a an AC appliance with an android device.

9.2) Requirements:
Arduino board, HC-05 bluetooth module, jumper wires, bread board, relay
module(5vDC,220vAC,7A), battery and android phone.

9.3) Schematic:

9.4) Procedure:

 Download the Application Bluetooth Terminal from the google play store in android.
 Connect the hardware as shown in the figure.
 Follow the code

26
#define switch 3;

void setup()

pinMode(switch,OUTPUT); //pin connected to relay signal

Serial.begin(9600); //initializing serial COM with a baud rate of 9600

digitalWrite(switch,LOW);

void loop()

if(Serial.available()==’1’) // when 1 entered in Bluetooth terminal

digitalWrite(switch,HIGH); // switching the pin 3 high

Serial.println(“Relay ON”);

if(Serial.available()==’0’) // when 0 enterd in the Bluetooth terminal

digitalWrite(switch,LOW); // switching the pin 3 low

Serial.println(“Relay OFF”);

else

Serial.println(“Invalid input”);

 Burn this program in the Arduino IDE


 Now disconnect the serial communication cable from the USB of Computer

27
 Give the supply through the external adapter of the Arduino board
 Now scan for new Bluetooth devices in the android phone and connect with the

‘HC-05’ name.

 Go in the Bluetooth terminal application downloaded in step 1.


 Select the device name in application and the terminal opens.
 Now enter the values 1 for switching the relay ON and 0 for switching it OFF.

9.5) Observations:
In the Bluetooth terminal app, the values 1 and 0 are able to switch the relay ON and OFF.

9.6) Result:
Android phone can be used to control even more relays in the same fashion. This will help to
control the appliances wirelessly.

28
10. Conclusion
Arduino is an open source platform for embedding, innovating, building, inventing and
achieving automation goals. This is a report which has only the basics to just get started.
Although the scope extends to infinity.

Currently people on industrial basis, use Arduino to control CNC machines, 3D printing,
home automation, radio sensing, weather stations, robotic controls, biometrics, medical
sciences and the list goes on and on.

And with the addition of IoT (internet of things), Arduino achieves a whole new level of
grounds.

29
10. References
10.1)https://www.arduino.cc/

10.2)https://www.adafruit.com/

10.3)https://en.wikipedia.org/

10.4) http://www.instructables.com/tag/type-id/category-technology/channel-arduino/

30

You might also like