You are on page 1of 60

ABSTRACT

ANDROID BASED VOICE CONTROLLED NOTICE BOARD

Notice Boards are a common occurrence in variety of institutions which we come


across daily basis. In the current scenario, the notice or advertisement boards are being
managed manually. In our case study of the actual history, there is a manual method of passing
information around as they are pinned on notice boards placed in strategic positions around the
university campus. This wastes a lot of resources like paper, printer ink, man power and also
brings about loss of time. Notice boards are often made of a material such as cork to facilitate
addition and removal of paper messages or it can be placed on digital devices such as
computers, phones so people can leave and erase messages for other people to read and see.

SOFTWARE:

 ARDUINO IDE

 EMBDDED CPP CODE

HARDWARE:

1. ATMEGA328 Microcontroller
2. Bluetooth Module
3. LED Dot Matrix Display Module
4. MAX7219 Shift Register IC
5. Regulated Power Supply

1
CHAPTER 1

INTRODUCTION

1.1. Introduction to the Project:


The aim of the project is to produce the output of the data which is given as the
input to the Arduino through the Bluetooth of the Android.

1.2. Motivation of the Project:


Currently we rely on putting up notices on the notice boards using papers. This
is time consuming and also there is wastage of paper. If we need to renew the notice
then we have to take a new hard copy. A separate person is required to take care of this
notice display. Now a days GSM modem based notice boards are also in use but they
require router in which cable connections are done which make it complex.

To make this project we got motivation from seeing the people who cannot
understand what the people actually say so by using this project we can make the
people efficient and every one can understand what they say and everyone understands
that.

1.3. Block Diagram Explanation:


The block diagram explains the connections in brief so that it will make the
connections easy and could be understood about the interface.

2
BLOCK DIAGRAM:

(ANDROID PHONE)

ATMEGA328 MAX7219 Shift Dot Matrix LED


BLUETOOTH
MODULE Register IC Display
MCU

REGULATED
POWER SUPPLY

3
Android Phone:

Used for giving the input to the module or the project.

Bluetooth Module:

Takes the data from the phone and gives that to the Arduino UNO.It just act as the
mediator between the mobile and Arduino.

Regulated Power Supply:

It gives power to the project.

Dot Matrix Display:

The output will be displayed on this board.

1.4. Components Used:

 ATMEGA328 Microcontroller
 Bluetooth Module
 LED Dot Matrix Display Module
 MAX7219 Shift Register IC
 Regulated Power Supply

Description in detail:

Various important blocks of system are:


1) Android application to detect voice commands: Android app on smart phone or tablet will
by use for speech recognition.
2) Bluetooth receiver and decoder: This device is used to interact with the Android
application.
3) Microcontroller: We have used ATMega 328 microcontroller. It interacts with Bluetooth
receiver, LED display, rolling display. In short, it is the heart of the system.

4
4) Rolling Display: This is the main display unit, which shows various scrolling messages.
5) LED display: It shows various messages. It is an optional device in this project and is just
used for testing purpose.

Advantages of Speech controlled electronic notice board:


1) Wireless Notice board is easy to install and easy to use.
2) Speech controlled rolling display is really helpful for disabled people or handicapped
people.

EXPENDITURE CHART:

Tab 1.1: EXPENDITURE CHART


S.No NAME OF THE EQUIPMENT COST
1. ARDUINO UNO ₹ 370
2. BLUETOOTH HC-05 ₹ 500
3. DOT MATRIX DISPLAY ₹ 850
4. POWER SUPPLY ₹ --
5. CONNECTING WIRES ₹ 20
TOTAL 1740

This is a low cost project and can be implemented in wide range.

1.5. Applications and Advantages:


There are many Applications of Electronic Notice Board Control By Human Voice, few of
them are listed below:
1) Advanced wireless notice board can be used in public transportation areas like Bus stations,
Railway stations and even at Airports.
2) Voice operated electronic notice board finds it main application in educational premises
5
like schools, colleges, university campuses. It can be used to display information like exam
schedule, notice, event notification and exam result announcement.

6
CHAPTER 2
LITERARY SURVEY

R. G. Gupta et al. in his paper basically focused on designing an electronic notice


board for different sectors like schools [1]. The notice can be send wirelessly within a second.
This creative technique can be used to display latest information. The contents of notice can
be changed anytime. This concept is designed to design an SMS based automated display
board that can replace the current usable programmable electronic display.

Abhishek Gupta et al. the main objective of this paper is to develop a wireless
notice board that displays message sent from the user and to design a simple, easy to install,
User friendly systems, which can display notice about information and time in a particular
way [2]. So that the user can help keep track of the information board easily every day and
every time he uses the system.

Ramchandra K. Gurav et al. in this paper it is focused on GSM (Global System


for Mobile) technology to design a digital notice board, “Wireless Notice Board using GSM
System” is wireless module which send message wirelessly with the help of GSM module [3].
This means that users or registered persons may be able to send messages from anywhere and
this message is displayed on the LCD display.

7
CHAPTER 3

METHODOLOGY

In this we have made this using Java framework Technology used,


EMBEDDED C is a general-purpose computer programming language that is
concurrent, class-based, object-oriented and specifically designed to have as few
implementation dependencies as possible. It allow the application developers to "write once,
run anywhere".

Android is a mobile operating system developed by Google. It is used by several


smartphones and tablets. Android phones typically come with several built-in applications and
also support third-party programs. Developers can create programs for Android mobile phones
usingAndroid studio and other software’s. Android programs are written in Java and run
through a Java virtual machine JVM that is optimized for mobile devices.

In view of the above it will be apparent that, there exists a need of electronic notice
board that enables efficient way to the user for displaying notice. By considering increasing
compactness of electronic systems, there is a need of embedding two or more systems
together. This project is an implementation of the idea of wireless communication between a
mobile phone and an Arduino controller. In this project work, as seen in fig-1we are designing
a system which consists of display unit, and android device using wireless technology. The
display unit consists of LED display that can be interfaced with ATmega328 microcontroller.

8
BLOCK DIAGRAM:

Fig 3.1: Block Diagram of the Project

Bluetooth is an open wireless protocol for exchanging data over short distances from
mobile devices, creating Personal Area Networks (PANs). It was originally conceived as a
wireless alternative to RS232 data cables. It can connect several devices, overcoming
problems of synchronization. Bluetooth will receive the signal sent by the Android application
device (mobile phone), and then send this signal to the microcontroller. In order to implement
this project, we need to use an Android application that is capable of performing the following

9
Functions:
 Convert voice data to text
 Send this text over to microcontroller via Bluetooth for displaying on
notice board

In the past we have seen paper and GSM based notice board which is time consuming and
difficult to operate. We are designing a notice board which displays the message by our voice
command and it is connected by the android application with the help of Bluetooth module.

STEPS FOR INTERFACING ARDUINO AND MOBILE:


 After connecting every required pin to the arduino thepower supply must be given.
 The mobiles Bluetooth should be switched on and scan for the devices.
 After finding HC-05, connect the mobile to the module by using the default pass word
(1234 or 0000).
 Open the AMR Voice app in your mobile and now you can connect to the device
through the app and send the data.
Bluetooth is an open wireless protocol for exchanging data over short distances from
mobile devices, creating Personal Area Networks (PANs). It was originally conceived as a
wireless alternative to RS232 data cables. It can connect several devices, overcoming
problems of synchronization. Bluetooth will receive the signal sent by the Android
application device (mobile phone), and then send this signal to the microcontroller. In
order to implement this project, we need to use an Android application that is capable of
performing the following Functions: Convert voice data to text. Send this text over to
microcontroller via bluetooth for displaying on notice board.

In the past we have seen paper and GSM based notice board which is time consuming
and difficult to operate. We are designing a notice board which displays the message by
our voice command and it is connected by the androiod application with the help of
Bluetooth module.

10
INTERFACING BLUETOOTH:

There are three main parts to this project. An Android smartphone, a Bluetooth transceiver,
and an Arduino.

Fig3.2: ARDUINO BLUETOOTH INTERFACING

HC 05/06 works on serial communication. The Android app is designed to send serial data to
the Arduino Bluetooth module when a button is pressed on the app. The Arduino Bluetooth
module at the other end receives the data and sends it to the Arduino through the TX pin of the
Bluetooth module (connected to RX pin of Arduino). The code uploaded to the Arduino
checks the received data and compares it. If the received data is 1, the LED turns ON. The
LED turns OFF when the received data is 0. You can open the serial monitor and watch the
received data while connecting.

11
Connecting the Arduino Bluetooth Hardware

FIG 3.3 BASIC INTERFACING EXAMPLE

This circuit is simple and small. There are only four connections to be made between the
Arduino and Bluetooth module!

Arduino Pins Bluetooth Pins

RX (Pin 0) ———> TX

TX (Pin 1) ———> RX

5V ———> VCC

GND ———> GND

12
Connect an LED positive to pin 13 of the Arduino through a resistance (valued between
220Ω–1KΩ). Connect its negative to GND, and you're done with the circuit!

FIG 3.4: ARDUINO POWER SUPPLY

You can connect the Bluetooth module to the Arduino using a set of jumper wires and a
connector.
Note: Don’t connect RX to RX and TX to TX on the Bluetooth and Arduino. You will receive
no data. Here, TX means transmit and RX means receive.

WORKING
Wireless communication technique used in this project is Bluetooth technology. Voice
recognition is done in the Android application. User has to install this Android application in
his/her smart phone or tablet. Then user has to give voice commands to this android app.
Android app then passes these commands to the microcontroller using wireless
communication. It means user doesn’t have to go near the Electronic notice board to change
the scrolling message.Then it passes these commands to the Rolling display which is made up
of Matrix LEDs.

13
CHAPTER 4
SOFTWARE AND SOURCE CODE

4.1. INTRODUCTION:

Fig 4.0: Brief diagram of project

The Arduino IDE is a cross-platform application written in Java, and is derived from the
IDE for the Processing programming language and the Wiring project. 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 make files or run programs on a command-line interface. Although
building on command-line is possible if required with some third-party tools such as Ino.

14
ARDUINO SKETCH

Fig 4.2: Schematic Diagram

Schematic Diagram :
Description :
We are using Arduino UNO Logic board. The 16x2 LCD is used to display status of
the circuit. The output voltage is given to adc channel of arduino. The microcontroller
atmega 328 processes the data and displays voltage value on LCD. The LCD data lines D7,
D6, D5, D4 are connected to 2,3,4,5 of arduino. The control lines RS, R/W ,En are connected
to 12,GND,11 respectively.

The bluetooth module Tx Pin is connected to Rx Pin of Microcontroller. The


microcontroller’s Tx Pin is connected to Rx Pin of LED Board through MAX232 IC which
acts as logic level converter.

15
4.2. FLOWCHAT:

START

START
BLUETOOTH
IF DATA AND IF DATA
RECEIVED CONNECT NOT
RECEIVED

GET DATA WAIT


FROM
BLUETOOTH

NO DATA YES
RECEIV
ED
COMPAR
E THE
DATA
WAIT RECEIVE
A C
D

B
PRINT PRINT TEXT
TEXT PRINT RELATED
RELATED TEXT TO ‘C’
TO ‘A’ RELATED
TO ‘B’

STOP

16
4.3. SOURCE CODE:
/*
Connections:
Matrix Display Arduino
VCC +5V
DIN MOSI (Pin 11)
CS SS(Slave Select Pin 10)
CLK SCK (Pin 13)
GND Gnd
*/
The UART communication takes place at 9600 baud rate.
#include <SPI.h> // Serial peripheral interface library for sending data through bluetooth
#include <Adafruit_GFX.h> //graphics library for display
#include <Max72xxPanel.h> //display library for dot matrix display

int pinCS = 10; // Attach CS to pin 10, DIN to MOSI (11) and CLK to SCK (13) int
numberOfHorizontalDisplays = 1;//number of h displays in our project it can be extended to as
many as we want
int numberOfVerticalDisplays = 4 ;//number of h displays in our project it can be extended to
as many as we want
Max72xxPanel matrix = Max72xxPanel(pinCS,
numberOfHorizontalDisplays,numberOfVerticalDisplays);
String MESSAGE1 = "VIGNAN COLLEGE INSTITUTE OF TECHNOLOGY AND
SCIENCE";
String MESSAGE2 = “ PROJECT GUIDED BY DR.N.DINESH KUMAR TO
4D1,4D3,4F3";
String MESSAGE3 = "VOICE CONTROLLED SINGLE ALPHABET INPUT NOTICE
BOARD"; //these messages can be changed according to our interest

int wait = 30; // In milliseconds


17
int val;
int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels
void setup()
{
matrix.setRotation(matrix.getRotation()+3); //1 - 90 2 - 180 3 - 270
matrix.setIntensity(12); // Use a value between 0 and 15 for brightness
Serial.begin(9600);
}
//setup() ends
void loop()
{
if (Serial.available()) //checks weather data is available
{
val = Serial.read();

while(1)
{

if (val == 'A') //for input A to print A


{
text1();
}

if (val == 'B') //for input B to print B

{
text2();
}
18
if (val == 'C') //for input C to print C

{
text3();
}
}
}
}
void text1()
{
for ( int i = 0 ; i < width * MESSAGE1.length() + matrix.width() - 1 - spacer; i++ )
{
matrix.fillScreen(LOW);
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 )
{
if ( letter < MESSAGE1.length() )
{
matrix.drawChar(x, y, MESSAGE1[letter], HIGH, LOW, 1);
}

letter--;
x -= width;
}

matrix.write(); // Send bitmap to display


delay(wait);
19
}
}
//----------------------------------------------------------------------------------------------
void text2()
{
for ( int i = 0 ; i < width * MESSAGE2.length() + matrix.width() - 1 - spacer; i++ )
{
matrix.fillScreen(LOW);
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 )
{
if ( letter < MESSAGE2.length() )
{
matrix.drawChar(x, y, MESSAGE2[letter], HIGH, LOW, 1);
}

letter--;
x -= width;
}

matrix.write(); // Send bitmap to display

delay(wait);
}

}
//-------------------------------------------------------------------------------------------------
void text3()
20
{
for ( int i = 0 ; i < width * MESSAGE3.length() + matrix.width() - 1 - spacer; i++ )
{

matrix.fillScreen(LOW);

int letter = i / width;


int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically

while ( x + width - spacer >= 0 && letter >= 0 )


{
if ( letter < MESSAGE3.length() )
matrix.drawChar(x, y, MESSAGE3[letter],HIGH, LOW, 1);
}

letter--;
x -= width;
}

matrix.write(); // Send bitmap to display

delay(wait);
}

21
CHAPTER 5

RESULTS

 After connecting every required pin to the arduino thepower supply must be given.
 The mobiles Bluetooth should be switched on and scan for the devices.
 After finding HC-05, connect the mobile to the module by using the default pass word
(1234 or 0000).
 Open the AMR Voice app in your mobile and now you can connect to the device
through the app and send the data.

Tab 5.1: Connections


COMPONENTS AND CONNECTIONS
ARDUINO UNO DISPLAY BLUETOOTH MODULE
0 Tx
1 Rx
10 CS
11 Din
13 CLK
GND GND GND
5v Vcc 5v

Fig 5.1: Output of the project

22
Fig 5.2: components

Fig 5.3: Output showing data ‘test’

23
Fig 5.4: Showing technology as output

Fig 5.5: Display without any input

24
CHAPTER 6
CONCLUSION

This application was designed for one specific department. But there are several ways
in which it can be utilized with a little more addition and editing. Thinking strictly for
academic purpose, it can be extended to a larger system keeping log of routines, results, notice
and schedules for different departments and respective teachers and students. A central notice
board can be added containing updates about the whole campus and not only a department. It
can be even extended to include more assisting options permanently or temporarily as per
requirement. If necessary, android assistant can function as an assistant not only for academic
purposes, but also for business and official purposes.

This project can be implemented using different of technology methods such as zigbee,
Wi-Fi, GSM, Ethernet etc. There is huge scope of further research and development in the
application using advance technology methods.

By introducing the concept of wireless technology in the Field of the communication


we can make our communication more efficient and faster, with greater efficiency. We can
display the messages with less errors and maintenance. This system can be used in college,
school, offices, railway station and commercial as well as personal used. The above technical
paper explains how we can develop as well as modify voice control Android based wireless
notice board. Wireless operations permit services, such as long range communications, that are
impossible or impractical to implement with the use of wires. It provides fast transfer of
information and are cheaper to install and maintain. It also provides user authentication in
order to avoid any misuse of proposed system. With the development of software and
hardware capabilities of mobile devices, there is an increased need for device-specific content,
what resulted in market changes. Speech recognition technology is of particular interest due to
the direct support of communications between human and computers. The same principle can
be applied to control the electrical appliances at a distant location. The project can be further

25
enhance to control different electrical application.

Future Development:

1) We can add feedback system in Android app. So that user can get feedback of the action
2) We can implement password so that any other person cannot control the system.

26
REFERENCES:
[1] Prof. R. G. Gupta, Nawale Shubhangi, Tupe Usha, Waghmare Priyanka “Android Based
E-Notice Board”, International Journal of Advance Research and Innovative Ideas in
Education (IJARIIE)-ISSN (O)-2395-4396 Vol-2 Issue-2 2016
[2] Abhishek Gupta, Rani Borkar, Samita Gawas, Sarang Joshi, “GSM Based Wireless Notice
Board”, International Journal of Technical Research and Applications e-ISSN: 2320-8163,
Special Issue 40 (KCCEMSR) (March 2016), PP. 30-33
[3] Mr. Ramchandra K. Gurav, Mr. Rohit Jagtap “Wireless Digital Notice Board Using GSM
Technology”, International Research Journal of Engineering and Technology (IRJET)
Volume: 02 Issue: 09, Dec-2015
[4]www.arduino.cc

27
APPENDIX [A]:
REGULATED POWER SUPPLY

The power supply unit is used to provide a constant 5V of DC supply from a 230V of
AC supply. These 5V DC will acts as power to different standard circuits. It mainly uses three
devices

1. Step Down Transfomer


2. Bridge wave rectifier
3. Voltage regulator

Fig : Block Diagram Of Regulated Power Supply

BRIDGE WAVE RECTIFIER

A rectifier is an electrical device that converts alternating current (AC) to direct current
(DC), a process known as rectification.The term rectifier describes a diode that is being used
to convert AC to DC.

A bridge-wave rectifier converts the whole of the input waveform to one of constant
polarity (positive or negative) at its output. Bridge-wave rectifier converts both polarities of
the input waveform to DC (direct current), and is more efficient. However, in a circuit with a
center tapped transformer (9-0-9) is used.

28
Fig : Bridge Rectifier Compilation

For single-phase AC, if the transformer is center-tapped, then two diodes back-to-
back(i.e. anodes-to-anode or cathode-to-cathode) can form a full-wave rectifier. Many
windings are required on the transformer secondary to obtain the same output voltage.

In this only two diodes are activated at a time i.e. D1 and D3 activate for positive cycle
and D2 and D4 activates for negative half cycle. D2 and D4 convert negative cycle to positive
cycle as it as negative supply and negative cycle as positive cycle at its output.

VOLTAGE REGULATOR

This is most common voltage regulator that is still used in embedded designs.
LM7805 voltage regulator is a linear regulator. With proper heat sink these LM78xx types can
handle even more than 1A current. They also have Thermal overload protection, Short circuit
protection. This will connect at the output of rectifier to get constant Dc supply instead of
ripple voltages. It mainly consists of 3 pins :

1. Input voltage

2. Output voltage

3. Ground

29
Fig : Block Diagram of Power Supply

Fig : Circuit Diagram Of Power Supply

30
APPENDIX [B]:
Cascaded 8x8 Dot Matrix Module :

cascadable 8×8 monochromatic LED dot matrix display module with onboard
MAXIM’s MAX7219 LED driver chip. The MAX7219 allows you to drive the LED matrix
using only three I/O pins of Arduino or any other microcontroller. It has pins CS (Chip
Select), DIN, CLK.

These pins are interfaced with the Arduino UNO.

Fig : Compilation Of Dot Matrix LED

As it can be seen in diagram CS, DIN, CLK Pins of dot matrix module are connected
to Pin 10,11 & 13 respectively. The module has MAX7219 LED shift register Ics. We are here
using 4 vertical displays. We can cascade multiple displays with it.
The MAX7219/MAX7221 is compact, serial input/output common-cathode display. It
works with SPI (Serial Peripheral Interface) Protocol.

31
Fig : Physical Image Of DOT Matrix Display

32
APPENDIX [C]:
Bluetooth Communication

Bluetooth is a wireless technology standard for exchanging data over short distances
(using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz) from fixed
and mobile devices, and building personal area networks (PANs). Invented by telecom
vendor Ericsson in 1994, it was originally conceived as a wireless alternative to RS-232 data
cables. It can connect several devices, overcoming problems of synchronization.

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed
for transparent wireless serial connection setup. HC-05 is 6-pin Module. The module has 6
pins labelled on the back, but most modules only have 4 of those populated with pogo pins.
KEY & STATE seem to be not required, as KEY is used for flashing the device and STATE
simply indicates if the device is awake or not. So that leaves only GND, VCC, TXD, RXD.

Fig : Bluetooth Module HC-05

33
For connecting The Module with microcontroller, we need to use the Serial (Tx and Rx) pins
provided on the board.

34
APPENDIX [D]:

Android APP :

Android App sends character data to HC-05 bluetooth module. It receives data and gives it to
microcontroller which processes data and performs switching operation of loads. We have to first pair
with bluetooth module by entering default pairing code : 1234. We can select bluetooth module in
connect option. We can send or receive serial data using this app.

Fig : Android App Overview

35
APPENDIX [E] :
Arduino

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-


use hardware and software. It is a single board microcontroller, descendant of the open-source
wiring platform designed to make the process of using electronics in multidisciplinary
projects. Arduino Uno, a microcontroller board based on the ATmega328 is used in this
project. The hardware consists of a simple open hardware design for the Arduino board with
an on-board input/output support. The software consists of a standard programming language
compiler and the boot loader that runs on the board. Arduino hardware is programmed using a
Wiring-based language (syntax and libraries), similar to C++ with some slight simplifications
and modifications, and a Processing-based integrated development environment.

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. The microcontroller on
the board is programmed using the Arduino programming language (based on Wiring) and the
Arduino development environment (based on Processing). Arduino projects can be stand-alone or
they can communicate with software running on a computer (e.g. Flash, Processing, MaxMSP and
Megunolink). The hardware reference designs (CAD files) are available under an open-
sourcelicense; you are free to adapt them to your needs. The open-source Arduino
environment makes it easy to write code and upload it to the i/o board. It runs on Windows,
Mac OS X, and Linux. In addition to all the features of the previous board, the Uno now uses
an ATmega8U2 instead of the FTDI chip. This allows for faster transfer rates, no drivers
needed for Linux or Mac (in file for Windows is needed), and the ability to have the Uno
show up as a keyboard, mouse, joystick, etc.

EXPLANATION IN DETAIL:

The Arduino microcontroller is an easy to use yet powerful single board computer that
has gained considerable traction in the hobby and professional market. The Arduino is open-

36
source, which means hardware is reasonably priced and development software is free. This
guide is for students in ME 2011, or students anywhere who are confronting the Arduino for
the first time. For advanced Arduino users, prowl the web; there are lots of resources. The
Arduino project was started in Italy to develop low cost hardware for interaction design. An
overview is on the Wikipedia entry for Arduino. The Arduino home page is
http://www.arduino.cc/. The Arduino hardware comes in several flavors. In the United States,
Sparkfun (www.sparkfun.com) is a good source for Arduino hardware. This guide covers the
Arduino Uno board (Sparkfun DEV-09950, $29.95), a good choice for students and
educators. With the Arduino board, you can write programs and create interface circuits to
read switches and other sensors, and to control motors and lights with very little effort. Many
of the pictures and drawings in this guide were taken from the documentation on the Arduino
site, the place to turn if you need more information. The Arduino section on the ME 2011 web
site, https://sites.google.com/a/umn.edu/me2011/, covers more on interfacing the Arduino to
the real world

An Arduino board consists of an 8-bit Atmel AVR microcontroller with


complementary components to facilitate programming and incorporation into other circuits.
An important aspect of the Arduino is the standard way that connectors are exposed, allowing
the CPU board to be connected to a variety of interchangeable add-on modules known as
shields.

37
Fig : Different Arduino’s and Their Sheilds

What You Need for a Working System ?


1. Arduino Duemilanove board
2. USB programming cable (A to B)
3. 9V battery or external power supply (for stand-alone operation)
4. Solderless breadboard for external circuits, and 22 g solid wire for connections
5. Host PC running the Arduino development environment.
Versions exist for Windows, Mac and Linux 1.3 Installing the Software Follow the
instructions on the Getting Started section of the Arduino web site,
http://arduino.cc/en/Guide/HomePage. Go all the way through the steps to where you see the
pin 13 LED blinking. This is the indication that you have all software and drivers successfully
installed and can start exploring with your own programs. 1.4 Connecting a Battery For stand-
alone operation, the board is powered by a battery rather than through the USB connection to
the computer. While the external power can be anywhere in the range of 6 to 24 V (for
example, you could use a car battery), a standard 9 V battery is convenient. While you could
jam the leads of a battery snap into the Vin and Gnd connections on the board, it is better to

38
solder the battery snap leads to a DC power plug and connect to the power jack on the board.
A suitable plug is part number 28760 from www.jameco.com. Here is what this looks like.

DIFFERENT TYPES OF SHIELDS:

Some shields communicate with the Arduino board directly over various pins, but
many shields are individually addressable via an I²C serial bus, allowing many shields to be
stacked and used in parallel. Official Arduino’s have used the mega AVR series of chips,
specifically the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560. A
handful of other processors have been used by Arduino compatibles. Most boards include a 5
volt linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some variants),
although some designs such as the Lily Pad run at 8 MHz and dispense with the onboard
voltage regulator due to specific form-factor restrictions. An Arduino's microcontroller is also
pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash
memory, compared with other devices that typically need an external programmer.

At a conceptual level, when using the Arduino software stack, all boards are
programmed over an RS-232 serial connection, but the way this is implemented varies by
hardware version. Serial Arduino boards contain a simple inverter circuit to convert between
RS-232-level and TTL-level signals. Current Arduino boards are programmed via USB,
implemented using USB-to-serial adapter chips such as the FTDI FT232. Some variants, such
as the Arduino Mini and the unofficial Board uno, use a detachable USB-to-serial adapter
board or cable, Bluetooth or other methods. (When used with traditional microcontroller tools
instead of the Arduino IDE, standard AVR ISP programming is used.)

EASE OF USAGE:

Arduino is an 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

39
The Arduino board exposes most of the microcontroller's I/O pins for use by other
circuits. The Diecimila, Duemilanove, and current Uno provide 14 digital I/O pins, six of
which can produce pulse-width modulated signals, and six analog inputs. These pins are on
the top of the board, via female 0.1 inch headers. Several plug-in application shields are also
commercially available.
FEATURES:

 ATmega328 microcontroller
 Input voltage - 7-12V
 14 Digital I/O Pins (6 PWM outputs)
 6 Analog Inputs
 32k Flash Memory
 16Mhz Clock Speed
The maximum values that Arduino can handle:
• Max frequency: 16MHz
• Max Voltage: 5V
• Max Current: 50mA
PIN DESCRIPTION:

• Arduino can be powered using power jack, USB port. Apart from this it can also be powered
by using a external battery or AC to DC adaptor through pin Vin.

Fig : Arduino UNO

40
• 5V, 3.3V: there is a inbuilt regulator on the board. Through this regulator a constant DC
supply of 5V, 3.3V is provided.
• Reset: This pin enables to reset the micro controller.
• IOREF: This pin acts as reference to the inputs given to the arduino board.
• There are 6 pins A0 – A5 through which analog input can be given to the arduino board.
• There are 14 digital pins 0-13. Among these (3,5,6,9,10,11) are PWM pins(pulse
width modulation) from which analog output can be taken from the arduino board.
• There is a inbuilt LED on pin 13.
• AREF- This pin acts as reference to the analog inputs.
• Rx,Tx are used for receiving and transmitting serial data.
• ICSP- (In circuit serial programming)- These pins enable the user to programme the chips
on the circuit.

41
APPENDIX [F]:
LIBRARIES:

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
There are total 1379 libraries present in the registered Open Source Official Arduino.
It is a feature of most Arduino boards that they have an LED and load resistor connected
between pin 13 and ground, a convenient feature for many simple tests. 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() functionat the bottom, to make it a valid C++
program. The Arduino IDE uses the GNU tool chain and AVR Libc to compile programs, and
uses avr to upload programs to the board. As the Arduino platform uses Atmel microcontrollers
Atmel’s development environment, AVR Studioor the newer Atmel Studio, may also
be used to develop software for the Arduino. The Arduino hardware reference designs are
distributed under a Creative Commons Attribution Share-Alike 2.5 license and are available
on the Arduino Web site. Layout and production files for some versions of the Arduino
hardware are also available.
The source code for the IDE and the on-board library are available and released under
the GPLv2 license. Arduino and Arduino-compatible boards uses of shields, which are printed
circuit boards that sit atop an Arduino, and plug into the normally supplied pin-headers. These
are expansions to the base Arduino. There are many functions of shields, from motor controls,
to breadboarding (prototyping).

42
Arduino IDE :
IDE stands for Integrated Development Environment. The IDE is a text editor-like
program that allows you to write ,compile and upload code in the microcontroller. The code
file is called as sketch. The coding language that Arduino uses is very much like C++ (“see
plus plus”), which is a common language in the world of computing. The toolbar buttons
allow you to verify and upload programs, create, open, and save sketches, and open the serial
monitor.

Fig : Arduino IDE Overview

The Simple Commands This section covers the small set of commands you need to
make the Arduino do something useful. These commands appear in order of priority. You can
make a great machine using only digital read, digital write and delay commands. Learning all
the commands here will take you to the next level. If you need more, consult the Arduino
language reference page at http://arduino.cc/en/Reference/HomePage. pinMode This
command, which goes in the setup() function, is used to set the direction of a digital I/O pin.
Set the pin to OUTPUT if the pin is driving and LED, motor or other device. Set the pin to
INPUT if the pin is reading a switch or other sensor. On power up or reset, all pins default to
inputs. This example sets pin 2 to an output and pin 3 to an input.

43
void setup()

{ pinMode(2,OUTPUT);

pinMode(3,INPUT);

} void loop()

{}

Serial.print 20 The Serial.print command lets you see what's going on inside the
Arduino from your computer. For example, you can see the result of a math operation to
determine if you are getting the right number. Or, you can see the state of a digital input pin to
see if the Arduino is a sensor or switch properly. When your interface circuits or program does
not seem to be working, use the Serial.print command to shed a little light on the situation. For
this command to show anything, you need to have the Arduino connected to the host computer
with the USB cable. For the command to work, the command Serial.begin(9600) must be
placed in the setup() function. After the program is uploaded, you must open the Serial
Monitor window to see the response.

There are two forms of the print command. Serial.print() prints on the same line while
Serial.println() starts the print on a new line. Here is a brief program to check if your board is
alive and connected to the PC void setup() { Serial.begin(9600); Serial.println("Hello World");
} void loop() {} Here is a program that loops in place, displaying the value of an I/O pin. This
is useful for checking the state of sensors or switches and to see if the Arduino is reading the
sensor properly. Try it out on your Arduino. After uploading the program, use a jumper wire
to alternately connect pin 2 to +5V and to Gnd.

44
void setup()

Serial.begin(9600);

void loop()

Serial.println(digitalRead(2));

delay(100);

If you wanted to see the states of pins 2 and 3 at the same time, you can chain a few print
commands, noting that the last command is a println to start a new line.

void setup()

{Serial.begin(9600); } void loop() {

Serial.print("pin 2 = ");

Serial.print(digitalRead(2));

Serial.print(" pin 3 = ");

Serial.println(digitalRead(3));

delay(100);

45
You may have noticed when trying this out that if you leave one of the pins
disconnected, its state follows the other. This is because a pin left floating has an undefined
value and will wander from high to low. So, use two jumper wires when trying out this
example. Here's one that checks the value of a variable after an addition. Because the
calculation is done just once, all the code is in the setup() function. The Serial.flush()

DigitalWrite

This command sets an I/O pin high (+5V) or low (0V) and is the workhorse for
commanding the outside world of lights, motors, and anything else interfaced to your board.
Use the pinMode() command in the setup() function to set the pin to an output.

Functions

Functions are a powerful programming feature that are used when you want to set up
an action that can be called from several places in the program. For example, let's say you
wanted an LED connected to pin 2 to flash 3 times as an alert, but that you needed to execute
the alert at three different places in the program. One solution would be to type in the flashing
code at the three separate program locations. This uses up precious code space and also means
that if you change the flash function, for example changing from 3 flashes to 4, you have to
change the code in three places. A better solution is to write the flash function as a subroutine
and to call it from the main body of the code.

Several things should be noted here. The function flasher() is defined outside the
setup() and loop() functions. When the main program encounters a flasher(); command, the
program immediately jumps to the function and starts executing the code there. When it
reaches the end of the function, the program returns to execute the command that immediately
follows the flasher(); command. It is this feature that allows you to call the subroutine from
several different places in the code. Parameters can be passed to and returned from functions,
but that feature is for the advanced programmer.

46
Basically Arduino sketch consists of two main functions namely

1. Void setup()

2. Void loop()

SETUP:
VOID SETUP():
Setup ()is called when a sketch starts. It is used to initializevariables, pin modes, start using
libraries etc. The setup () will only run once, after each power up or reset of the Arduino
board.

Syntax:
Void setup ()
{
Statements;
}
LOOP:
Void loop():
After creating a setup () function which initializes and sets the initial values, the loop ()
function does precisely what its name suggests, and loops consecutively, allowing your
program to change and respond. It is used to actively control the Arduino board.
Syntax:
Void setup()
{
Statements;
}
Void loop ()
{
Statements;
47
}

Fig: Arduino IDE

Arduino Programming Basics:

The Arduino Uno can be programmed with the arduino software.Select"ArduinoUno from
the Tools>Board menu (according to the micro controller on your board).

The ATmega328 on the ArduinoUno comes pre burned with a boot loader that allows
you to upload new code to it without the use of an external hardware programmer .It
communicates using the original STK500protocol.

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

STRUCTURE:

An Arduino program runs in two parts: Void setup()

Void loop()

setup() Is preparation, and loop() is execution. In the setup section, always at the top of your
program ,you would set pin Modes, initialize serial communication, etc. The loop section is
the code to be executed &reading inputs, Triggering outputs, etc.

48
Setup()

The setup() function is called when a sketch starts.Use it to initialize variables, pin
modes ,start using libraries ,etc .The setup function will only run once, after each power up
or reset of the Arduino board.

Loop()

After creating a setup() function, which initializes and sets the initial values, the
loop()function does precisely what its name suggests, and loops consecutively, allowing
your program to change and respond. Use it to actively control the Arduino board.

Serial communication functions

Used for communication between the Arduino board and a computer or other devices.
All Arduino boards have atleast one serial port (also known as a UART or USART) :

Serial .It communicates on digital pins0 (RX) and 1(TX) as well as with the computer via
USB . Thus , if you use these functions, you cannot also use pins0 and 1 for digital input or
output.

We 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.available()
 Serial.begin()
 Serial.print()
 Serial read()
 Serial.write()
 Serial.begin()

49
Description

Sets the data rate in bits per second (baud) for serial data transmission . For communicating
with the computer , use one of these rates

:1200,2400,4800,9600,115200.

You can, however, specify other rates – for example ,to communicate over pins 0 and 1 with
a component that requires a particular baudrate.

Syntax : Serial.begin(speed) Parameters

speed: in bits per second(baud) Serial.available()

Get the number of bytes (characters) available for reading from the serial port.

Serial.read()

Reads serial data

Serial.print();

Serial.print(“ HELLO “)

To send a single byte, use Serial.write().

Syntax

Serial.print(val)

Serial.print(val, format)

Arduino Libraries

Arduino support many libraries, using these we can easily write the programs for any
applications in Arduino. Libraries provide extra functionality for use in sketches, e.g.
working with hardware or manipulating data. To use a library in a sketch, select it from
Sketch> Import Library.

50
Standard Libraries

 EEPROM-reading and writing to "permanent" storage


 Ethernet-for connecting to the internet using the Arduino Ethernet Shield
 Firmata -for communicating with applications on the computer using a
standard serial protocol.
 Liquid Crystal – for controlling liquid crystal displays(LCDs)
 SD –for reading and writing SD cards
 Servo –for controlling servo motors
 SPI-for communicating with devices using the Serial Peripheral Interface
(SPI)Bus
 Software Serial- for serial communication on any digital pins
 Stepper-for controlling stepper motors
 Wire-Two Wire Interface(TWI/I2C) for sending and receiving data over a
net of devices or sensors.
In our project we are using Software Serial – library for serial communication on any
digital pins.

Serial Library

The Arduino hardware has built – in support for serial communication on pins0 and 1
( which also goes to the computer via the USB connection). The native serial support
happens via a piece of hardware ( built into the chip) called a UART . This hardware allows
the Atmega chip to receive serial communication even while working on other tasks , as
long as there room in the 64 byte serial buffer.

The Software Serial library has been developed to allow serial communication on other
digital pins of the Arduino, using software to replicate the functionality (hence the name
"SoftwareSerial").It is possible to have multiple software serial ports with speeds
upto115200 bps. A parameter enables inverted signaling for devices which require that
protocol.

51
SoftwareSerial(rxPin, txPin)

Description:

A call to SoftwareSerial(rxPin, txPin) creates a new Software Serial object, whose name you
need to provide as in the example below.

We need to call SoftwareSerial.begin()to enable communication.

rxPin:

the pin on which to receive serial data txPin :the pin on which to transmit serial
dataSoftwareSerial: available() Description

Get thenumberof bytes (characters) available forreadingfromasoftware serial port. This


is data that's alreadyarrived and stored in theserial receivebuffer.

Syntax

Returns

The number ofbytes available to read

SoftwareSerial:
begin(speed) Description

Sets thespeed (baudrate) for theserial communication. Supported baud rates are300, 1200,

2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and
115200. Parameters speed: thebaud rate(long)

Returns none

SoftwareSerial: read

Description

52
Return a character that was received on theRX pin of thesoftwareserial port. Note that
onlyone SoftwareSerialinstancecan receive incomingdataat a time(selectwhich onewith
thelisten() function).

ParametersnoneReturns

the character read, or -1 if noneis available

SoftwareSerial: listen() Description

Enables theselected softwareserial port to listen. Onlyonesoftwareserial port can listen at a


time; data that arrives forotherports will be discarded. Anydataalreadyreceived is discarded
duringthecallto listen()(unless thegiven instanceis alreadylistening).

Syntax mySerial.listen()

Parameters my Serial: the name of the instance to listen

Returns None

Software Serial: is Listening()

Description

Tests to see if requested software serial port is actively listening.

Syntax my Serial.isListening()
]

File

 New

Creates a new instance of the editor, with the bare minimum structure of a sketch already in
place.
 Open
Allows to load a sketch file browsing through the computer drives and folders.
53
 Open Recent
Provides a short list of the most recent sketches, ready to be opened.
 Sketchbook
Shows the current sketches within the sketchbook folder structure; clicking on any name
opens the corresponding sketch in a new editor instance.
 Examples

Any example provided by the Arduino Software (IDE) or library shows up in this menu item.
All the examples are structured in a tree that allows easy access by topic or library.
 Close

Closes the instance of the Arduino Software from which it is clicked.


 Save

Saves the sketch with the current name. If the file hasn't been named before, a name will be
provided in a "Save as.." window.
 Save as...
Allows to save the current sketch with a different name.
 Page Setup
It shows the Page Setup window for printing.
 Print

Sends the current sketch to the printer according to the settings defined in Page Setup.
 Preferences

Opens the Preferences window where some settings of the IDE may be customized, as the
language of the IDE interface.
 Quit
Closes all IDE windows. The same sketches open when Quit was chosen will be automatically
reopened the next time you start the IDE.

Edit

 Undo/Redo

Goes back of one or more steps you did while editing; when you go back, you may go forward
with Redo.

54
 Cut
Removes the selected text from the editor and places it into the clipboard.
 Copy
Duplicates the selected text in the editor and places it into the clipboard.
 Copy for Forum
Copies the code of your sketch to the clipboard in a form suitable for posting to the forum,
complete with syntax coloring.
 Copy as HTML
Copies the code of your sketch to the clipboard as HTML, suitable for embedding in web
pages.
 Paste

Puts the contents of the clipboard at the cursor position, in the editor.
 Select All
Selects and highlights the whole content of the editor.
 Comment/Uncomment

Puts or removes the // comment marker at the beginning of each selected line.
 Increase/Decrease Indent
Adds or subtracts a space at the beginning of each selected line, moving the text one space on
the right or eliminating a space at the beginning.
 Find

Opens the Find and Replace window where you can specify text to search inside the current
sketch according to several options.
 Find Next
Highlights the next occurrence - if any - of the string specified as the search item in the Find
window, relative to the cursor position.
 Find Previous
Highlights the previous occurrence - if any - of the string specified as the search item in the
Find window relative to the cursor position.

55
Sketch

 Verify/Compile

Checks your sketch for errors compiling it; it will report memory usage for code and variables
in the console area.
 Upload
Compiles and loads the binary file onto the configured board through the configured Port.
 Upload Using Programmer
This will overwrite the bootloader on the board; you will need to use Tools > Burn Bootloader
to restore it and be able to Upload to USB serial port again. However, it allows you to use the
full capacity of the Flash memory for your sketch. Please note that this command will NOT
burn the fuses. To do so a Tools -> Burn Bootloader command must be executed.
 Export Compiled Binary
Saves a .hex file that may be kept as archive or sent to the board using other tools.
 Show Sketch Folder
Opens the current sketch folder.
 Include Library
Adds a library to your sketch by inserting #include statements at the start of your code. For
more details, see libraries below. Additionally, from this menu item you can access the Library
Manager and import new libraries from .zip files.
 Add File...
Adds a source file to the sketch (it will be copied from its current location). The new file
appears in a new tab in the sketch window. Files can be removed from the sketch using the tab
menu accessible clicking on the small triangle icon below the serial monitor one on the right
side o the toolbar.

Tools

 Auto Format
This formats your code nicely: i.e. indents it so that opening and closing curly braces line up,
and that the statements inside curly braces are indented more.

56
 Archive Sketch
Archives a copy of the current sketch in .zip format. The archive is placed in the same
directory as the sketch.
 Fix Encoding & Reload
Fixes possible discrepancies between the editor char map encoding and other operating
systems char maps.
 Serial Monitor
Opens the serial monitor window and initiates the exchange of data with any connected board
on the currently selected Port. This usually resets the board, if the board supports Reset over
serial port opening.
 Board

Select the board that you're using. See below for descriptions of the various boards.
 Port
This menu contains all the serial devices (real or virtual) on your machine. It should
automatically refresh every time you open the top-level tools menu.
 Programmer

For selecting a harware programmer when programming a board or chip and not using the
onboard USB-serial connection. Normally you won't need this, but if you're burning a
bootloader to a new microcontroller, you will use this.
 Burn Bootloader
The items in this menu allow you to burn a bootloader onto the microcontroller on an Arduino
board. This is not required for normal use of an Arduino or Genuino board but is useful if you
purchase a new ATmega microcontroller (which normally come without a bootloader). Ensure
that you've selected the correct board from the Boards menu before burning the bootloader on
the target board. This command also set the right fuses.

Help

Here you find easy access to a number of documents that come with the Arduino Software
(IDE). You have access to Getting Started, Reference, this guide to the IDE and other

57
documents locally, without an internet connection. The documents are a local copy of the
online ones and may link back to our online website.

 Find in Reference
This is the only interactive function of the Help menu: it directly selects the relevant page in
the local copy of the Reference for the function or command under the cursor.

Sketchbook
The Arduino Software (IDE) uses the concept of a sketchbook: a standard place to store your
programs (or sketches). The sketches in your sketchbook can be opened from the File >
Sketchbook menu or from the Open button on the toolbar. The first time you run the Arduino
software, it will automatically create a directory for your sketchbook. You can view or change
the location of the sketchbook location from with the Preferences dialog.

Important command options for arduino based programming :

Verify
Checks your code for errors compiling it.

Upload
Compiles your code and uploads it to the configured board. See uploading below
for details.

New
Creates a new sketch.

58
Open
Presents a menu of all the sketches in your sketchbook. Clicking one will open it
within the current window overwriting its content.

Save
Saves your sketch.

Serial Monitor
Opens the serial monitor.

Coding Style:

Style refers to your own particular style for creating code and includes layout,
conventions for using case, headers, and use of comments. All code must follow correct
syntax, but there are many different styles you can use. Here are some suggestions: Start
every program with a comment header that has the program name and perhaps a brief
 Description of what the program does. Use indentation to line things up.
Function name and braces are in column one, then use
 Indents in multiples of 2 or 4 to mark code chunks, things inside loops and so
on. 26 Mark major sections or functions with a comment header line or two
 Have just the right number of comments, not too few and not too many.
Assume the reader
 knows the programming language so have the comment be instructive. Here is
an example of an instructive comment digitalWrite(4,HIGH) // turn on motor
and here is a useless comment digitalWrite(4,HIGH) // set pin 4 HIGH

59
 You need not comment every line. In fact, commenting every line is generally
bad practice. Add the comments when you create the code. If you tell yourself,
"Oh, I'll add the comments
 When the code is finished", you will never do it.
Common Coding Errors:

 Forgetting the semi-colon at the end of a statement


 Misspelling a command
 Omitting opening or closing braces

60

You might also like