67
EMBEDDED SYSTEM DEVELOPMENT A SUMMER INTERN REPORT Submitted by AYUSH SULTANIA Roll No: 00596402813 in partial fulfillment of Summer Internship for the award of the degree of BACHELOR OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION ENGINEERING Maharaja Agrasen Institute of Technology

Embedded system development-Arduino UNO

Embed Size (px)

Citation preview

Page 1: Embedded system development-Arduino UNO

EMBEDDED SYSTEM DEVELOPMENT

A SUMMER INTERN REPORT

Submitted by

AYUSH SULTANIA Roll No: 00596402813

in partial fulfillment of Summer Internship for the award of the degree

of

BACHELOR OF TECHNOLOGY

IN ELECTRONICS AND COMMUNICATION ENGINEERING

Maharaja Agrasen Institute of Technology

Guru Gobind Singh Indraprastha University, Delhi

2013-2017

Page 2: Embedded system development-Arduino UNO

TABLE OF CONTENTSTitle Page ……(1)

Certificate by the Supervisor ……(2)

Acknowledgement ……(3)

List of Figures ……(4)

List of Tables ……(5)

List of Photographs ……(6)

ABSTRACT ……(7)

CHAPTER (1) INTRODUCTION

1.1 Aim of project

1.2 Outlines of report …

1.3 Methodology …

CHAPTER(2) LITERATURE REVIEW

2.4 Embedded system

2.5 Arduino uno

CHAPTER (3)ARDUINO UNO

3.1 Overview

3.2 Pin Diagram

3.3 Internal Description

CHAPTER(4) ARDUINO SOFTWARE

4.1 Arduino IDE

4.2 Serial Communication

Page 3: Embedded system development-Arduino UNO

CHAPTER (5)PROGRAMMES USING ARDUINO UNO

5.1 Glowing LED’s in sequence

5.2 Digital temperature sensor interfacing using LCD

5.3 keypad interfacing

5.4 GPS interfacing

5.5 RFID interfacing

5.6 Ultrasonic Sensors

CHAPTER(6) RESULTS AND DISCUSSIONS

6.1 Results and Conclusions

6.3 Uses and further scope

CHAPTER 7 REFERENCES

Page 4: Embedded system development-Arduino UNO

CERTIFICATE

This is to certify that this project report entitled Embedded system development

by Ayush Sultania (Roll no: 00596402813) , submitted in partial fulfillment of the

requirements for the degree of Bachelor of Technology in Electronics and

Communication Engineering of the Maharaja Agrasen Institute of technology,

Delhi, during the academic year 2015, is a bonafide record of work carried out

under our guidance and supervision.

The results embodied in this report have not been submitted to any other

University or Institution for the award of any degree or diploma.

date : -------------------

Teacher in charge

Institution Rubber Stamp

Page 5: Embedded system development-Arduino UNO

ACKNOWLEDGEMENT

First of all I am indebted to almighty God . I have no words to say thanks to him.

I am thankful to our training company “VMDD Technologies” for providing

wonderful training platform.

We would like to express our special thanks of gratitude to our guide Mr.

Deevanshu Shukla as well as our director Prof. M. L. Goyal, our chairman Dr.

Nand Kishore Garg and our HOD Dr. Neelam Sharma who gave us the golden

opportunity to do this wonderful research on the topic “Arduino” which also

helped us in doing a lot of research and we came to know about so many new

things that we are really thankful to them.

Secondly we would like to thank our parents and friends who helped us a lot in

finalizing this project within the time frame.

Page 6: Embedded system development-Arduino UNO

LIST OF FIGURES

LIST OF TABLES

SN

O

FIGURE

NO

FIGURE DESCRIPTION PAGE

NO

1 3.1 Arduino Pin Diagram 16

2 3.2 ATmega 328P 17

3 3.3 ATmega Ports 18

4 4.1 Arduino Board 24

5 4.2 Driver Installation 24-25

6 4.3 Launching Arduino IDE 25

7 4.4 Blink Example 26

8 4.5 Selecting Board 26

9 4.6 Selecting Port 27

10 4.7 Serial Communication 28

11 5.1 Glowing LED’s 29

12 5.2 Temperature Sensor interfacing 34

13 5.3 Hex keypad interfacing 37

14 5.4 GPS interfacing 44

15 5.5 Ultrasonic interfacing 49

16 6.1 Comparing Arduino with other software 52

Page 7: Embedded system development-Arduino UNO

S.No. Table No. Description Page No.1 3.1 Comparison of ATmega 328P

with others19

2. 3.2 Arduino Specifications 22

LIST OF PHOTOGRAPHSS.No. Photograph

No.Description Page No.

1. 2.1 Creator of Arduino

14

2. 6.1 My custom Board 53

ABSTRACT

Page 8: Embedded system development-Arduino UNO

This is a report about Arduino board and programming environment. It contains

basic working of Arduino , different types of Arduino boards, interfacing with

Arduino programming environment, how to program, basic instructions regarding

that and interfacing of a few sensors is shown in the content.

In fifth chapter different projects based on Arduino uno is explored. Few

additional software like visual studio was used.

Outcome of this report is learning to program in Arduino programming

environment and understanding concepts behind its working. Interfacing different

sensor modules with Arduino is also included.

This report will help you making your project much easier using Arduino.

CHAPTER 1 : INTRODUCTION

1.1 Aim of the project

Page 9: Embedded system development-Arduino UNO

The aim of the project is to develop some understanding about what embedded system is and how we can design our own modules using Arduino uno.

Apart from these it also provides knowledge about some software platform.

1.2 Outlines of Report

This report contains a detailed information about all the components used in this project. The components used are:

Arduino UNO

Temperature sensor

GPS module

Ultrasonic sensor

LCD

LED

Bluetooth module

Keypad interfacing

A detailed report about each and every component is described in separate chapter.

Chapter 2 contains information about Embedded System.

Chapter 3 contains information about Arduino uno.

Chapter 4 contains information about Arduino software.

Chapter 5 contains information about Programmming using Arduino.

Chapter 6 contains Results and discussions.

1.3 Methodologies

The idea of this project is to give information about the accident to the ambulance and family

members, so we have chose GSM technology to give the information by sending SMS.

Page 10: Embedded system development-Arduino UNO

Sending SMS alone can’t help the driver, if we send and an SMS saying that accident had

occurred where the ambulance will come without knowing the location of the accident. So we

include GPS location in the SMS which we are sending so that the ambulance will have perfect

information about where and when the accident has occurred. For this we use GPS module to

extract the location of the accident, the GPS data will contain the latitude and longitude values

using which we can find the accurate position of the accident place.

To run the GPS and GSM module we use Arduino UNO board which has ATmega328

microcontroller. The Arduino is a very user friendly device which can be easily interfaced with

any sensors or modules and is very compact in size.

Also we can make rfid card detector using Arduino UNO using which one can make detect his

own RFID card if available like if one wants to check balance in metro card, attendance record

in office, and many more.

Finally we can sense the room temperature and distance of any object.One can also glow LED’s

in some beautiful dancing patterns and display them on LCD.

CHAPTER 2 : LITERATURE REVIEW

A literature review is collection of a critical, unbiased, and comprehensive evaluation of

published information in a chosen and specific area of study of interest. It gives a general

understanding of findings of the research work, conclusions, and recommendations and thereby

Page 11: Embedded system development-Arduino UNO

brings out their strengths and weaknesses. This helps in identifying gaps, scope for further work

and generalized concepts in the existing body of knowledge.

2.1 Embedded System

An embedded system is some combination of hardware and software, either fixed in capability or

programmable, that is specifically designed for a particular function. Industrial machines,

automobiles, medical equipment, cameras, household appliances, airplanes, vending machines

and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible

hosts of an embedded system.

In embedded systems, software commonly known as firmware is hidden inside the same

hardware rather than in some other hardware. Basically embedded systems are task specific

devices. One of its most important characteristic is gives the output within the time constraints or

you can say they are time bound systems. These embedded systems help to make the work more

convenient and accurate. So, we often use these embedded systems in simple and complicated

devices too. We use these embedded systems in our real life for many devices and applications

such as Calculators, microwave, television remote control, home security and neighborhood

traffic control systems, etc.

Modern embedded systems are often based on microcontrollers (i.e. CPUs with integrated

memory or peripheral interfaces) but ordinary microprocessors (using external chips for memory

and peripheral interface circuits) are also still common, especially in more complex systems. In

either case, the processor(s) used may be types ranging from general purpose to those specialized

in certain class of computations or even custom designed for the application at hand. A common

standard class of dedicated processors is the digital signal processor (DSP).

Since the embedded system is dedicated to specific tasks, design engineers can optimize it to

reduce the size and cost of the product and increase the reliability and performance. Some

embedded systems are mass-produced, benefiting from economies of scale.

Page 12: Embedded system development-Arduino UNO

Embedded systems range from portable devices such as digital watches and MP3 players, to

large stationary installations like traffic lights, factory controllers, and largely complex systems

like hybrid vehicles, MRI, and avionics. Complexity varies from low, with a

single microcontroller chip, to very high with multiple units, peripherals and networks mounted

inside a large or enclosure.

Author Steve Heath

There are many definitions for this but the best way to define it is to describe it in terms of what

it is not and with examples of how it is used.

An embedded system is a microprocessor-based system that is built to control a function or

range of functions and is not designed to be programmed by the end user in the same way that a

PC is. Yes, a user can make choices concerning functionality but cannot change the functionality

of the system by adding/replacing software. With a PC, this is exactly what a user can do: one

minute the PC is a word processor and the next it’s a games machine simply by changing the

software. An embedded system is designed to perform one particular task albeit with choices and

different options. The last point is important because it differentiates itself from the world of the

PC where the end user does reprogram it whenever a different software package is bought and

run. However, PCs have provided an easily accessible source of hardware and software for

embedded systems and it should be no surprise that they form the basis of many embedded

systems. To reflect this, a very detailed design example is included at the end of this book that

uses a PC in this way to build a sophisticated data logging system for a race car. If this need to

control the physical world is so great, what is so special about embedded systems that has led to

the widespread use of microprocessors? There are several major reasons and these have

increased over the years as the technology has progressed and developed. Replacement for

discrete logic-based circuits The microprocessor came about almost by accident

Page 13: Embedded system development-Arduino UNO

2.2 Arduino UNO

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's

intended for anyone making interactive projects. Arduino can take the input from many sensors

attached to it & can give the output to many lights, motors etc.

There is no prerequisite knowledge of Advance electronics for operating Arduino. All you

should know is basic electronics and C programming language.

Arduino platform mainly contains a Hardware Board called Arduino Board & software Arduino

IDE to program it.

Other external hardware like Sensor Modules, Motors, lights etc. could be attached with the

board.

ARDUINO BOARDS:-

Arduino UNO. Arduino MEGA.

Arduino MINI. Arduino DUE.

Arduino YUN. Arduino Lily pad.

The most common Board used is Arduino UNO. “UNO" means one in Italian and was chosen to

mark the release of Arduino Software (IDE) 1.0. The Uno board and version 1.0 of Arduino

Software (IDE) were the reference versions of Arduino, now evolved to newer releases. 

Who created Arduino UNO ?

Arduino started in 2005 as a project for students at the Interaction Design Institute Ivrea in Ivrea,

Italy. At that time program students used a "BASIC Stamp" at a cost of $100, considered

expensive for students. Massimo Banzi, one of the founders, taught at Ivrea. The name

"Arduino" comes from a bar in Ivrea, where some of the founders of the project used to meet.

The bar, in turn, has been named after Arduin of Ivrea, who was the margrave of Ivrea and king

of Italy from 1002 to 1014.

Page 14: Embedded system development-Arduino UNO

Colombian student Hernando Barragan created the Wiring development platform which served

as the basis for Arduino. Following the completion of the Wiring platform, its lighter, less

expensive versions  were created and made available to the open-source community; associated

researchers, including David Cuartielles, promoted the idea. The Arduino's initial core team

consisted of Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis.

Page 15: Embedded system development-Arduino UNO

CHAPTER 3 : ARDUINO UNO

3.1 Overview

Arduino is an open-source computer hardware and software company, project and user

community that designs and manufactures microcontroller-based kits for building digital devices

and interactive objects that can sense and control the physical world.

The project is based on a family of microcontroller board designs manufactured primarily by

SmartProjects in Italy,  and also by several other vendors, using various 8-

bit Atmel AVR microcontrollers or 32-bit Atmel ARM processors. These systems provide sets of

digital and analog I/O pins that can be interfaced to various expansion boards ("shields") and

other circuits. The boards feature serial communications interfaces, including USB on some

models, for loading programs from personal computers. For programming the microcontrollers,

the Arduino platform provides an integrated development environment (IDE) based on

the Processing project, which includes support for C, C++ and Java programming languages.

The first Arduino was introduced in 2005, aiming to provide an inexpensive and easy way for

novices and professionals to create devices that interact with their environment

using sensors and actuators. Common examples of such devices intended for beginner hobbyists

include simple robots, thermostats, and motion detectors.

Arduino boards are available commercially in preassembled form, or as do-it-yourself kits. The

hardware design specifications are openly available, allowing the Arduino boards to be

manufactured by anyone. Adafruit Industries estimated in mid-2011 that over 300,000 official

Arduinos had been commercially produced, and in 2013 that 700,000 official boards were in

users' hands.

The Uno is a microcontroller board based on the ATmega328P   . It has 14 digital input/output

pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB

connection, a power jack, an ICSP header and a reset button. It contains everything needed to

support the microcontroller; simply connect it to a computer with a USB cable or power it with a

AC-to-DC adapter or battery to get started.. You can tinker with your UNO without worrying too

Page 16: Embedded system development-Arduino UNO

much about doing something wrong, worst case scenario you can replace the chip for a few

dollars and start over again.

"Uno" means one in Italian and was chosen to mark the release of Arduino Software (IDE) 1.0.

The Uno board and version 1.0 of Arduino Software (IDE) were the reference versions of

Arduino, now evolved to newer releases. The Uno board is the first in a series of USB Arduino

boards, and the reference model for the Arduino platform; for an extensive list of current, past or

outdated boards see the Arduino index of boards.

3.2 Pin Diagram

Arduino

Arduino/Genuino Uno is a microcontroller board based on the ATmega328P   . It has 14 digital

input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz

crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains

everything needed to support the microcontroller; simply connect it to a computer with a USB

Page 17: Embedded system development-Arduino UNO

cable or power it with a AC-to-DC adapter or battery to get started.. You can tinker with your

UNO without worrying too much about doing something wrong, worst case scenario you can

replace the chip for a few dollars and start over again.

Atmega 328p

The ATmega48PA/88PA/168PA/328P is a low-power CMOS 8-bit microcontroller based on the

AVR enhanced RISC architecture(RISC, or Reduced Instruction Set Computer. is a type of

microprocessor architecture that utilizes a small, highly-optimized set of instructions). By

executing powerful instructions in a single clock cycle, the ATmega48PA/88PA/168PA/328P

achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize

power consumption versus processing speed.

Page 18: Embedded system development-Arduino UNO

The AVR(Advanced Virtual RISC) core combines a rich instruction set with 32 general purpose

working registers. All the 32 registers are directly connected to the Arithmetic Logic Unit

(ALU), allowing two independent registers to be accessed in one single instruction executed in

one clock cycle. The resulting architecture is more code efficient while achieving throughputs up

to ten times faster than conventional CISC microcontrollers. The

ATmega48PA/88PA/168PA/328P provides the following features: 4/8/16/32K bytes of In

System Programmable Flash with Read-While-Write capabilities, 256/512/512/1K bytes

EEPROM, 512/1K/1K/2K bytes SRAM, 23 general purpose I/O lines, 32 general purpose

working registers, three flexible Timer/Counters with compare modes, internal and external

interrupts, a serial programmable USART, a byte-oriented 2-wire Serial Interface, an SPI serial

port, a 6-channel 10-bit ADC , a programmable Watchdog Timer with internal Oscillator, and

five software selectable power saving modes.

The Idle mode stops the CPU while allowing the SRAM, Timer/Counters, USART, 2-wire Serial

Interface, SPI port, and interrupt system to continue functioning.

The Power-down mode saves the register contents but freezes the Oscillator, disabling all other

chip functions until the next interrupt or hardware reset. In Power-save mode, the asynchronous

timer continues to run, allowing the user to maintain a timer base while the rest of the device is

sleeping.

Page 19: Embedded system development-Arduino UNO

The ADC Noise Reduction mode stops the CPU and all I/O modules except asynchronous timer

and ADC, to minimize switching noise during ADC conversions. In Standby mode, the

crystal/resonator Oscillator is running while the rest of the device is sleeping. This allows very

fast start-up combined with low power consumption.

The device is manufactured using Atmel’s high density non-volatile memory technology. The

On-chip ISP Flash allows the program memory to be reprogrammed In-System through an SPI

serial interface, by a conventional non-volatile memory programmer, or by an On-chip Boot

program running on the AVR core. The Boot program can use any interface to download the

application program in the Application Flash memory.

Comparison Between ATmega48PA, ATmega88PA, ATmega168PA and ATmega328P

The ATmega48PA, ATmega88PA, ATmega168PA and ATmega328P differ only in memory

sizes, boot loader support, and interrupt vector sizes. Table summarizes the different memory

and interrupt vector sizes for the three devices.

Table: memory summary

DEVICE FLASH EEPROM RAM INTERRUPT SIZEATmega48PA 4K Bytes 256 Bytes 512 Bytes 1 instruction word/vectorATmega88PA 8K Bytes 512 Bytes 1K Bytes 1 instruction word/vectorATmega168PA 16K Bytes 512 Bytes 1K Bytes 2 instruction word/vectorATmega328P 32K Bytes 1K Bytes 2K Bytes 2 instruction word/vector

3.3 Internal Description

Power

The Arduino/Genuino Uno board can be powered via the USB connection or with an external

power supply. The power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery.

The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power

jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER

connector.

Page 20: Embedded system development-Arduino UNO

The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V,

however, the 5V pin may supply less than five volts and the board may become unstable. If using

more than 12V, the voltage regulator may overheat and damage the board. The recommended

range is 7 to 12 volts.

The power pins are as follows:

 Vin. The input voltage to the Arduino/Genuino board when it's using an external power source

(as opposed to 5 volts from the USB connection or other regulated power source). You can

supply voltage through this pin, or, if supplying voltage via the power jack, access it through this

pin.

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied

with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of

the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can

damage your board. We don't advise it.

3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.

GND. Ground pins.

IOREF. This pin on the Arduino/Genuino board provides the voltage reference with which the

microcontroller operates. A properly configured shield can read the IOREF pin voltage and

select the appropriate power source or enable voltage translators on the outputs to work with the

5V or 3.3V.

Memory

The ATmega328 has 32 KB (with 0.5 KB occupied by the bootloader). It also has 2 KB of

SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

Input and Output

Each of the 14 digital pins on the Uno can be used as an input or output,

using pinMode(),digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin

can provide or receive 20 mA as recommended operating condition and has an internal pull-up

resistor (disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that must

not be exceeded on any I/O pin to avoid permanent damage to the microcontroller.

Page 21: Embedded system development-Arduino UNO

In addition , some pins have specialized functions:

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins

are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low

value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using

the SPI library.

LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the LED

is on, when the pin is LOW, it's off.

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution

(i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible

to change the upper end of their range using the AREF pin and the analogReference() function.

There are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to

shields which block the one on the board.

Communication

Arduino/Genuino Uno has a number of facilities for communicating with a computer, another

Arduino/Genuino board, or other microcontrollers. The ATmega328 provides UART TTL (5V)

serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2

on the board channels this serial communication over USB and appears as a virtual com port to

software on the computer. The 16U2 firmware uses the standard USB COM drivers, and no

external driver is needed. However, on Windows, a .inf file is required. The Arduino Software

(IDE) includes a serial monitor which allows simple textual data to be sent to and from the

Page 22: Embedded system development-Arduino UNO

board. The RX and TX LEDs on the board will flash when data is being transmitted via the

USB-to-serial chip and USB connection to the computer (but not for serial communication on

pins 0 and 1).

Table: Arduino Specifications

Microcontroller ATmega328POperating Voltage 5V

Input Voltage (recommended) 7-12 V

Input Voltage (limit) 6-20 V

Digital I/O Pins 14 (of which 6 provide PWM Output)

PWM Digital I/O Pins 6

Analog Input Pins 6

DC Current per I/O pin 20 mADC Current for 3.3V Pin 50 mA

Flash Memory 32 KB (ATmega 328P) of which 0.5 KB used by bootloader

SRAM 2 KB (ATmega 328P)

EEPROM 1 KB (ATmega328P)

Clock Speed 16 MHz

Length 68.6 mm

Width 53.4 mm

Weight 25 g

Page 23: Embedded system development-Arduino UNO

CHAPTER 4 : ARDUINO SOFTWARE

4.1 Arduino IDE

WHAT IS IDE?

• The Arduino integrated development environment (IDE) is a cross-platform application

written in Java, and derives from the IDE for the Processing programming language and

the Wiring projects.

• 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. A program or code written for Arduino is called a "sketch

• Arduino programs are written in C or C++. The Arduino IDE comes with a software

library called "Wiring" from the original Wiring project, which makes many common

input/output operations much easier.

• The source code for the IDE is available and released under the GNU General Public

License, version 2.

How to start Arduino software?

1. Get an Arduino board and USB cable

Page 24: Embedded system development-Arduino UNO

2. Download the Arduino Software (IDE)

Download Arduino IDE from https://www.arduino.cc/en/Main/Software

3. Connect the board

Connect your Arduino UNO hardware to PC or Laptop via USB cable.

4. Install the drivers

Step 1:Open Device Manager

Step 2:Double click the unknown Arduino Uno device, a property window pops up

Page 25: Embedded system development-Arduino UNO

Step 3 : Choose the 'Driver' tab, and select 'Update Driver...'

Step 4: Select drivers folder and click OK

5. Launch the Arduino application

Page 26: Embedded system development-Arduino UNO

6. Open the blink example

7. Select your board

Page 27: Embedded system development-Arduino UNO

8. Select your serial port

9. Upload the program

4.2 Serial Communication

Used for communication between theArduino and a computer or other devices. All Arduino

boards have at least one serial port (also known as a UART or USART): Serial. It communicates

on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if one use these

functions, one cannot also use pins 0 and 1 for digital input or output.

Page 28: Embedded system development-Arduino UNO

One 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().

Information passes between the computer and Arduino through USB cable. Information is

transmitted as 0’s and 1’s , also known as bits.

• Compiling turns your program into binary data (ones and zeros)

• Uploading sends the bits through USB cable to the Arduino

• The two LEDs near the USB connector blink when data is transmitted

• RX blinks when the Arduino is receiving data

• TX blinks when the Arduino is transmitting data

Page 29: Embedded system development-Arduino UNO

CHAPTER 5 : PROGRAMMES USING ARDUINO UNO

5.1 Glowing LED’s in sequence

This program glows Led’s in sequence according to character typed from keyboard

and also display that character on LCD screen.

Code

#include<LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

int thisPin;

void setup()

{

Page 30: Embedded system development-Arduino UNO

lcd.begin(16,2);

Serial.begin(9600);

Serial.println("-----------Main Menu--------------");

Serial.println("Press a for LED1");

Serial.println("Press b for LED2");

Serial.println("Press c for LED3");

Serial.println("Press d for LED4");

Serial.println("Press e for LED5");

Serial.println("press any key to switch off the LED");

Serial.println("-------------------------------------");

for( thisPin=2;thisPin<7;thisPin++);

{

pinMode(thisPin,OUTPUT);

}

}

void loop()

{

if(Serial.available()>0)

{

char rx=Serial.read();

switch(rx)

Page 31: Embedded system development-Arduino UNO

{

case 'a':

Serial.println("LED1 is ON");

lcd.setCursor(0,1);

lcd.print("LED1");

digitalWrite(2,HIGH);

break;

case 'b':

Serial.println("LED2 is ON");

lcd.setCursor(5,1);

lcd.print("LED2");

digitalWrite(3,HIGH);

break;

case 'c':

Serial.println("LED3 is ON");

lcd.setCursor(11,1);

lcd.print("LED3");

digitalWrite(4,HIGH);

break;

case 'd':

Serial.println("LED4 is ON");

Page 32: Embedded system development-Arduino UNO

lcd.setCursor(0,2);

lcd.print("LED4");

digitalWrite(5,HIGH);

break;

case 'e':

Serial.println("LED5 is ON");

lcd.setCursor(8,2);

lcd.print("LED5");

digitalWrite(6,HIGH);

break;

default:

for(int thisPin=2;thisPin<7;thisPin++)

{

digitalWrite(thisPin,LOW);

}

Serial.println("All LEDs are off");

lcd.clear();

}

}

}

Page 33: Embedded system development-Arduino UNO

5.2 Digital temperature sensor interfacing using LCD

Components Required:

1 ) Developments board.

2) 2*16 LCD

3) Digital Temperature Sensor

4) Pot-Meter (10k)

5) Resistor 560 ohm

6) Bread Board

7) Couple of Jumper Wire

Temperature Sensor - Waterproof (DS18B20)

Description: 

This sealed digital temperature probe lets you precisely measure temperatures in wet

environments with a simple 1-Wire interface. The DS18B20 provides 9 to 12-bit (configurable)

temperature readings over a 1-Wire interface,so that only one wire (and ground) needs to be

connected from a central microprocessor.

What is 2*16 LCD

• LCD (Liquid Crystal Display) screen is an electronic display module and find a wide

range of applications. A 16x2 LCD display is very basic module and is very commonly

used in various devices and circuits.

• A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In

this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,

Page 34: Embedded system development-Arduino UNO

namely, Command and Data.

Circuit Connection of Temperature Sensors Using LCD and Atmega

Code :

#include<OneWire.h>

#include<DallasTemperature.h>

#include<LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

#define singleWire 6

OneWire ourWire(singleWire);

DallasTemperature sensors(&ourWire);

Page 35: Embedded system development-Arduino UNO

void setup()

{

Serial.begin(9600);

Serial.print("Temperature value");

lcd.begin(16,2);

lcd.print("***Temperature***");

sensors.begin();

}

void loop()

{

sensors.requestTemperatures();

Serial.print(sensors.getTempCByIndex(0));

Serial.println(" C");

lcd.setCursor(0,1);

lcd.print(sensors.getTempCByIndex(0));

lcd.print(" C,");

Serial.print(sensors.getTempFByIndex(0));

Serial.println(" F");

lcd.setCursor(8,1);

lcd.print(sensors.getTempFByIndex(0));

lcd.print(" F");

Page 36: Embedded system development-Arduino UNO

}

5.3 keypad interfacing

Components Required:

1.) Custom Board

2.) LED RED

3.) LED GREEN

4.) POT-METER(10k)

5.) 2 x 16 LCD

6.) Breadboard

7.) Resistor 560 ohm

8.) Couple of Jumper Wire

9.) Hex-Keypad

Interfacing hex keypad to Atmega-328p

This article is about how to interface a hex keypad to Atmega-328. Hex keypad is a very

important component in embedded systems and the typical applications are code locks,

calculators, automation systems or simply any thing that requires a character  or numeric input.

Hex keypad.

Hex key pad is simply an arrangement 0f 16 push button switches in a 4X4 matrix form.

Typically a hex keypad will have keys for number 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and letters A, B, C,

D, *, #. The hex keypad will have 8 connection wires namely R1, R2, R3, R4 and C1, C2, C3,

C4 representing the rows and columns respectively. The schematic diagram and photo of a

typical hex keypad is shown in the figure below.

Page 37: Embedded system development-Arduino UNO

Code :

#include<Password.h>

#include<Keypad.h>

#include<LiquidCrystal.h>

Password password=Password("1#3*5");

int len=5;//size of password

int ledRed=11;//for Wrong

int ledGreen=12;//for Success

int ilosc;//number of clicks

LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);

Page 38: Embedded system development-Arduino UNO

const byte ROWS=4;

const byte COLS=4;

char keys[ROWS][COLS]={

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

};

byte rowPins[ROWS]={5,4,3,2};

byte colPins[COLS]={9,8,7,6};

Keypad keypad=Keypad(makeKeymap(keys),rowPins,colPins,ROWS,COLS);

void setup()

{

keypad.addEventListener(keypadEvent);

Serial.begin(9600);

pinMode(ledRed,OUTPUT);

pinMode(ledGreen,OUTPUT);

lcd.begin(16,2);

lcd.setCursor(1,0);

lcd.print("PLEASE ENTER PIN");

}

Page 39: Embedded system development-Arduino UNO

void loop()

{

keypad.getKey();

}

void keypadEvent(KeypadEvent eKey)

{

switch(keypad.getState())

{

case PRESSED:

Serial.print("pressed: ");

Serial.println(eKey);

}

Serial.println(ilosc);

if(ilosc == 1)

{

lcd.clear();

lcd.setCursor(1,0);

lcd.print(" <PIN> ");

lcd.setCursor(0,1);

lcd.print("*_");

}

Page 40: Embedded system development-Arduino UNO

if(ilosc == 2)

{

lcd.clear();

lcd.setCursor(1,0);

lcd.print(" <PIN> ");

lcd.setCursor(0,1);

lcd.print("**_");

}

if(ilosc == 3)

{

lcd.clear();

lcd.setCursor(1,0);

lcd.print(" <PIN> ");

lcd.setCursor(0,1);

lcd.print("***_");

}

if(ilosc==4)

{

lcd.clear();

lcd.setCursor(1,0);

lcd.print(" <PIN> ");

Page 41: Embedded system development-Arduino UNO

lcd.setCursor(0,1);

lcd.print("****_");

}

if(ilosc==5)

{

lcd.clear();

lcd.setCursor(1,0);

lcd.print(" <PIN> ");

lcd.setCursor(0,1);

lcd.print("*****_");

}

if(ilosc == len)

{

delay(250);

checkPassword();

ilosc=0;

}

}

void checkPassword()

{

if(password.evaluate())

Page 42: Embedded system development-Arduino UNO

{

ilosc = 0;

Serial.println("Success");

digitalWrite(ledRed,LOW);

digitalWrite(ledGreen,HIGH);

lcd.clear();

lcd.setCursor(0,1);

lcd.print("<<SUCCESS>>");

}

else

{

ilosc = 0;

password.reset();

Serial.println("Wrong");

digitalWrite(ledGreen,LOW);

lcd.clear();

lcd.setCursor(1,0);

lcd.print(" :WELCOME:");

lcd.setCursor(0,1);

lcd.print("PLEASE ENTER PIN");

}

Page 43: Embedded system development-Arduino UNO

}

5.4 GPS interfacing

Components Required:

1.) Custom Board

2.) POT-METER(10k)

3.) 2 x 16 LCD

4.) Breadboard

5.) Resistor 560 ohm

6.) Couple of Jumper Wire

7.) Ublox GPS Module

What is GPS?

The Global Positioning System (GPS) is a satellite-based navigation system made up of a

network of 24 satellites placed into orbit by the U.S. Department of Defense. GPS was originally

intended for military applications, but in the 1980s, the government made the system available

for civilian use. GPS works in any weather conditions, anywhere in the world, 24 hours a day.

There are no subscription fees or setup charges to use GPS.

How Does GPS Work:

The GPS system currently has 31 active satellites in orbits inclined 55 degrees to the equator.

The satellites orbit about 20,000km from the earth's surface and make two orbits per day.The

orbits are designed so that there are always 6 satellites in view, from most places on the earth.

The GPS receiver can determine your position in three dimensions - east, north and altitude.

GPS Receiver:

GPS Receiver received the information in string format, transmitted by Satellites, which uses this

information to calculate different parameters between it and satellites. With information from

Page 44: Embedded system development-Arduino UNO

satellites, a GPS receiver can fix it location on the ground from the known position of the

satellites. Now I want to drag your attention on the purpose of this project. In this project, we are

going to display ‘Latitude & Longitude’ used for positioning of an object on the earth. So let’s

talk about how a GPS receiver fixes its location on the ground, as i above said and the find the

location of an object on the earth.

Pin Configuration of U-Blox GPS:

1.VCC: +5v Power Supply

2.TX : Data Transmission

3.RX : Data Receiver

4.GND: Ground

Page 45: Embedded system development-Arduino UNO

Code :

#include<TinyGPS.h>

#include<SoftwareSerial.h>

long lat,lon;

TinyGPS gps;

SoftwareSerial gpsSerial(3,4);

void setup()

{

Serial.begin(9600);

gpsSerial.begin(9600);

}

void loop()

{

while(gpsSerial.available())

{

if(gps.encode(gpsSerial.read()))

{

gps.get_position(&lat,&lon);

Serial.print("Receive GPS signal is:");

Serial.println("Position:");

Page 46: Embedded system development-Arduino UNO

Serial.print("Longitude:");

Serial.print(lon);

Serial.print(" ");

Serial.print("Latitude:");

Serial.print(lat);

}

}

}

5.5 RFID interfacing

Code :

//add libraries to your project

#include<AddicoreRFID.h>

#include<LiquidCrystal.h>

#include<SPI.h>

#define uchar unsigned char

#define uint unsigned int

//class to include functions of rfid

AddicoreRFID myRFID;

int chipSelectPin=10;

#define MAX_LEN 16

Page 47: Embedded system development-Arduino UNO

void setup(){

//led

lcd.begin(16,2);

lcd.println("RFID World");

pinMode(6,OUTPUT);

//convert binary to human readable form

SPI.begin();

//initialise or activate rfid

//as setup execute only once

digitalWrite(6,LOW);

//initialise the rfid

myRFID.AddicoreRFID_Init();

}

unsigned char structure[16];

unsigned char status;

void loop(){

uchar status;

uchar str[MAX_LEN];

status=myRFID.AddicoreRFID_Request(PICC_REQIDL,str);

status=myRFIDAddicoreRFID_Anticoll(str);

if(status==MI_OK){

Page 48: Embedded system development-Arduino UNO

lcd.setCursor(0,1);

lcd.print("Tag ID:");

lcd.setCursor(8,1);

lcd.print(str[0]);

digitalWrite(6,HIGH);

delay(1000);

digitalWrite(6,LOW);

}

myRFID.AddicoreRFID_Halt();

}

5.6 Ultrasonic SensorsComponents Required:

1.) Custom Board

2.) POT-METER(10k)

3.) 2 x 16 LCD

4.) Breadboard

5.) Resistor 560 ohm

6.) Couple of Jumper Wire

7.) HC-SR04

Interfacing of ultrasonic Sensors withAtmega-328p

HC-SR04 Ultrasonic distance sensors is a popular and low cost solution for non-contact

distance measurement function. It is able to measure distances from 1cm to 400cm with

an accuracy of about 3mm. This module includes ultrasonic transmitter, ultrasonic

receiver and its control circuit.

HC-SR04 module has 4 pins :

VCC – 5V power supply

Page 49: Embedded system development-Arduino UNO

TRIG – Trigger Pin

ECHO – Echo Pin

GND – Ground power supply

Code :

#include<LiquidCrystal.h>

LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);

Page 50: Embedded system development-Arduino UNO

const int trigPin=2;

const int echoPin=4;

void setup()

{

lcd.begin(16,2);

Serial.begin(9600);

Serial.print("Distance Between Object and Sensors");

}

void loop()

{

long inches,cm,duration;

pinMode(trigPin,OUTPUT);

digitalWrite(trigPin,LOW);

delayMicroseconds(2);

digitalWrite(trigPin,HIGH);

delayMicroseconds(10);

digitalWrite(trigPin,LOW);

pinMode(echoPin,INPUT);

duration=pulseIn(echoPin,HIGH);//time

inches=microsecondsToInches(duration);

cm=microsecondsToCentimeter(duration);

Page 51: Embedded system development-Arduino UNO

lcd.clear();

lcd.print("Distance Finder:");

lcd.setCursor(0,1);

lcd.print("INCHES");

lcd.setCursor(7,1);

lcd.print(inches);

Serial.print("INCHES");

lcd.setCursor(10,1);

lcd.print("CM:");

lcd.setCursor(13,1);

lcd.print(cm);

Serial.print(cm);

Serial.println("centimeter");

}

long microsecondsToInches(long microseconds)

{

return microseconds /74/2;

}

long microsecondsToCentimeter(long microseconds)

{

return microseconds /29/2;

Page 52: Embedded system development-Arduino UNO

CHAPTER 6 : RESULTS AND DISCUSSIONS

6.1 Results and Conclusions

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.

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.

Figure 1 GOOGLE trends comparing ARDUINO with its biggest competitors

Page 53: Embedded system development-Arduino UNO

6.3 Uses and further scopeArduino was basically designed 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 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.

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

project that can be programmed to read temperatures, control a motor, and sense touch.

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.

Page 54: Embedded system development-Arduino UNO

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

Various light projects like

Multicolor light display

Seven-segment LED display

Double seven-segment LED dice

LED array

Page 55: Embedded system development-Arduino UNO

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

CHAPTER 7 REFERENCES

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

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

3. http://www.google.co.in

4. http://forum.arduino.cc/index.php?topic=146315.0

5. http://www.circuitstoday.com/interfacing-hex-keypad-to-arduino

6. http://read.pudn.com - steve heath

7. hackveda-VMDD Technologies

Page 56: Embedded system development-Arduino UNO