You are on page 1of 36

ANDROID BLUETOOTH

CONTROLLED ROBOT
Project ID:3111
A Technical Project Report
submitted in partial fulfillment of
the requirement for the B.Tech.
under Biju Patnaik University of Technology, Rourkela.
Submitted By

GOURAB SAHOO
SANAM SINGH

Roll No. # ECE201116067


Roll No.# ECE201110041

OCTOBER - 2014

Under the guidance of

Mr. NIHAR RANJAN SAHU

APEX INSTITUTE OF TECHNOLOGY & MANAGEMENT


Pahala, Bhubaneswar, Odisha 752101, India
APEX INSTITUTE OF TECHNOLOGY & MANAGEMENT

Pahala, Bhubaneswar, Odisha 752101, India

CERTIFICATE
This is to certify that the Project work entitled Android Bluetooth Controlled
Robot is a bonafide work being done by Gourab Sahoo and Sanam Singh
bearing Registration No1101314088, 1101314110 of ECE branch.
This Project report is submitted in partial fulfillment for the requirement of
the B.Tech. degree under Biju Patnaik University of Technology, Rourkela,
Odisha.

(Mr. NIHAR RANJAN SAHU)


Project Guide

(Dr. Satya Ranjan Pattnaik)


B.Tech Project Coordinator

(Prof. RC das)
PRINCIPAL

ABSTRACT
A robot is usually an electro-mechanical machine that is guided by computer and electronic
programming. Many robots have been built for manufacturing purpose and can be found in
factories around the world. Designing of the latest inverted ROBOT which can be
controlling using an APP for android mobile. We are developing the remote buttons in the
android app by which we can control the robot motion with them. And in which we use
Bluetooth communication to interface controller and android. Controller can be interfaced to
the Bluetooth module though UART protocol. According to commands received from
android the robot motion can be controlled. The consistent output of a robotic system along
with quality and repeatability are unmatched. Pick and Place robots can be reprogrammable
and tooling can be interchanged to provide for multiple applications. The project is designed
to control a robotic vehicle using an android application. Bluetooth device is interfaced to
the control unit on the robot for sensing the signals transmitted by the android application.
This data is conveyed to the control unit which moves the robot as desired. An 8051 series
microcontroller is used in this project as control device.
Remote operation is achieved by any smart-phone/Tablet etc., with Android OS, upon a GUI
(Graphical User Interface) based touch screen operation. Transmitting end uses an android
application device remote through which commands are transmitted. At the receiver end,
these commands are used for controlling the robot in all directions such as forward,
backward and left or right etc. At the receiving end the movement is achieved by two motors
that are interfaced to the microcontroller. Serial communication data sent from the android
application is received by a Bluetooth receiver interfaced to the microcontroller. The
program on the microcontroller refers to the serial data to generate respective output based
on the input data to operate the motors through a motor driver IC. The motors are interfaced
to the control unit through motor driver IC

ACKNOWLEDGEMENT
We would like to express our immense sense of gratitude to our guide, Mr. Nihar Ranjan
Sahu, for his valuable instructions, guidance and support throughout our project..
We again owes our special thanks to Dr. Satya Ranjan Pattnaik, B-tech Project
Coordinator for giving us an opportunity to do this report.
And finally thanks to Prof. R.C. Das, Principal, APEX Institute of technology and
management for his continued drive for better quality in everything that happens at APEX.
This report is a dedicated contribution towards that greater goal.

Mr. GOURAB SAHOO

(ECE201116067)
Mr.
SANAM SINGH
(ECE201110041)

ii

TABLE OF CONTENTS
ABSTRACT....................................................................................i
ACKNOWLEDGEMENT...................................................................ii
LIST OF TABLE.............................................................................iv
LIST OF FIGURES...........................................................................i
1. INTRODUCTION........................................................................1
2. PROJECT PLAN..........................................................................2
2.1 Block Diagram.......................................................................................... 2
2.2 Description............................................................................................... 2
3. CIRCUIT DESCRIPTION..............................................................5
4. AVR MICROCONTROLER.............................................................6
5. DEVICE OVERVIEW....................................................................7
5.1 Basic families........................................................................................... 7
5.2 Internal data memory.............................................................................. 8
5.3 Internal registers...................................................................................... 8
5.4 Instruction set.......................................................................................... 9
5.5 MCU speed............................................................................................... 9
5.6 Features................................................................................................. 10
5.7 Pin Configuration.................................................................................... 12
6. BLUETOOTH DRIVER...............................................................16
6.1 Bluetooth serial interface module..........................................................16
6.2 Bluetooth adapter.................................................................................. 16
7. MOTOR DRIVER......................................................................18
8. FUTURE WORK.......................................................................19
REFERENCES..............................................................................20

iii

LIST OF TABLE
Table5.1.Alternate Pin of Port A..13
Table5.2.Alternate Pin of Port B..14
Table5.3.Alternate Pin of Port C..14
Table5.4.Alternate Pin of Port D..15

iv

LIST OF FIGURES
Figure2. 1 Block Diagram.................................................................................................2

Figure3. 1 Circuit description...........................................................................................5


Figure 5.1 Pin Diagram12

Figure 6. 1 HC-05 Bluetooth model................................................................................17

Figure 7. 1 L293D Motor Driver Model.........................................................................18

Android Bluetooth controlled robot

1. INTRODUCTION
Robot is a mechanical device that sometimes resembles a human and is capable of
performing a variety of often complex human tasks on command or by being programmed in
advance. Here at this robot I have used a Bluetooth module to control the robot via 2 BO
motors at 100RPM approx the robot is control by an android phone application
Microcontroller used is AVR with the Bluetooth module HC-05.The Bluetooth module used
is a HC-05 in smd package which works on a 3.3v and have a serial communication with
any device connected to it the communication speed can be configured on various speed via
AT Command.
The BT module is a SPP supported profile so it can be connected easily to any module or
phone. In this profile the data can be sent and receive to module. The BT module is
connected to the RX pin of microcontroller.
The L293D is a motor driver IC to operate the motors in any direction required dependent on
the logic applied to the logic pins.

Android Bluetooth controlled robot

2. PROJECT PLAN
2.1 Block Diagram

Figure2. 3 Block Diagram

The block diagram consists of the following components:

Android phone

AVR Microcontroller

Bluetooth Model

Arduino

Motor Driver

Motors

2.2 Description
Android phone:
It is type of phone which contains android operating system through which we can do the
Bluetooth operation and can operate the robot.
AVR Microcontroller:
It stands for Advanced Virtual RISC(Reduced instruction set computing). Microcontroller is
the heart of the Project. Where every- action is under the control of the Microcontroller. The
1

Android Bluetooth controlled robot

micro-controller used here is ATmega8535L.It is an 8-bit low power high performance AVR
micro-controller. It has 8K Bytes of Flash memory, 512 Bytes of SRAM and 512 Bytes of
EEPROM.
Bluetooth Model:
Here in this project we use the HC-05 Bluetooth Model. HC-05 embedded Bluetooth serial
communication module (can be short for module) has two work modes: order-response work
mode and automatic connection work mode. And there are three work roles (Master, Slave
and Loopback) at the automatic connection work mode. When the module is at the automatic
connection work mode, it will follow the default way set lastly to transmit the data
automatically. When the module is at the order-response work mode, user can send the AT
command to the module to set the control parameters and sent control order. The work mode
of module can be switched by controlling the module PIN (PIO11) input level.
Arduino:
Arduino is a single-board microcontroller, intended to make building interactive objects or
environments more accessible.[1] The hardware consists of an open-source hardware board
designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel ARM. Current
models feature a USB interface, 6 analog input pins, as well as 14 digital I/O pins that
accommodate various extension boards.
Introduced in 2005, the Arduino's designers sought to provide an inexpensive and easy way
for hobbyists, students, and professionals to create devices that interact with their
environment using sensors and actuators. Common examples for beginner hobbyists include
simple robots, thermostats and motion detectors. It comes with a simple integrated
development environment (IDE) that runs on regular personal computers and allows users to
write programs for Arduino using C or C++.
Motor driver:
It is an electronic circuit that enables a voltage to be applied across a load in either direction.
These circuits are often used in robotics and other applications to allow DC motors to run
forwards and backwards.
Most DC-to-AC converters (power inverters), most AC/AC converters, the DC-to-DC push
pull converter, most motor controllers, and many other kinds of power electronics use H

Android Bluetooth controlled robot

bridges. In particular, a bipolar stepper motor is almost invariably driven by a motor


controller containing two H bridges.
Motor:
The Robot use two 12v DC motors.

Android Bluetooth controlled robot

3. CIRCUIT DESCRIPTION

Figure3. 4 Circuit description

The above circuit contains the following components:


AVR microcontroller
Motor driver L293D
Blutooth model HC-05

Android Bluetooth controlled robot

4. AVR MICROCONTROLER
The AVR architecture was conceived by two students at the Norwegian Institute of
Technology (NTH) Alf-Egil Bogen and Vegard Wollan.
The original AVR MCU was developed at a local ASIC house in Trondheim, Norway called
Nordic VLSI at the time, now Nordic Semiconductor, where Bogen and Wollan were
working as students. It was known as a RISC (Micro RISC) and was available as silicon
IP/building block from Nordic VLSI. When the technology was sold to Atmel from Nordic
VLSI, the internal architecture was further developed by Bogen and Wollan at Atmel
Norway, a subsidiary of Atmel. The designers worked closely with compiler writers at IAR
Systems to ensure that the instruction set provided for more efficient compilation of highlevel languages. Atmel says that the name AVR is not an acronym and does not stand for
anything in particular. The creators of the AVR give no definitive answer as to what the term
"AVR" stands for. However, it is commonly accepted that AVR stands for Alf (Egil Bogen)
and Vegard (Wollan)'s RISC processor. Note that the use of "AVR" in this article generally
refers to the 8-bit RISC line of Atmel AVR Microcontrollers.
Among the first of the AVR line was the AT90S8515, which in a 40-pin DIP package has the
same pinout as an 8051 microcontroller, including the external multiplexed address and data
bus. The polarity of the RESET line was opposite (8051's having an active-high RESET,
while the AVR has an active-low RESET), but other than that the pinout was identical.
The AVR 8-bit microcontroller architecture was introduced in 1997. By 2003, Atmel had
shipped 500 million AVR flash microcontrollers.

5. DEVICE OVERVIEW

Android Bluetooth controlled robot

The AVR is a modified Harvard architecture machine where program and data are stored in
separate physical memory systems that appear in different address spaces, but having the
ability to read data items from program memory using special instructions.

5.1 Basic families


AVRs are generally classified into following:

tinyAVR the ATtiny series

0.516 kB program memory

632-pin package

Limited peripheral set

megaAVR the ATmega series

4512 kB program memory

28100-pin package

Extended instruction set (multiply instructions and instructions for handling

larger program memories)

Extensive peripheral set


XMEGA the ATxmega series

16384 kB program memory

4464100-pin package (A4, A3, A1)

Extended performance features, such as DMA, "Event System", and

cryptography support.

Extensive peripheral set with ADCs


Application-specific AVR
megaAVRs with special features not found on the other members of the

AVR family, such as LCD controller, USB controller, advanced PWM, CAN, etc.
6

Android Bluetooth controlled robot

FPSLIC (AVR with FPGA)

FPGA 5K to 40K gates

SRAM for the AVR program code, unlike all other AVRs

AVR core can run at up to 50 MHz

32-bit AVRs

In 2006 Atmel released microcontrollers based on the 32-bit AVR32 architecture. They
include SIMD and DSP instructions, along with other audio and video processing features.
This 32-bit family of devices is intended to compete with the ARM based processors. The
instruction set is similar to other RISC cores, but it is not compatible with the original AVR
or any of the various ARM cores.

5.2 Internal data memory


The data address space consists of the register file, I/O registers, and SRAM

5.3 Internal registers


The AVRs have 32 single-byte registers and are classified as 8-bit RISC devices.
In the tiny and mega variants of the AVR architecture, the working registers are mapped in
as the first 32 memory addresses (0000 16001F16), followed by 64 I/O registers (0020 16
005F16). In devices with many peripherals, these registers are followed by 160 extended
I/O registers, only accessible as memory-mapped I/O (00601600FF16).
Actual SRAM starts after these register sections, at address 0060 16 or, in devices with
extended I/O, at 010016.
Even though there are separate addressing schemes and optimized opcodes for accessing the
register file and the first 64 I/O registers, all can still be addressed and manipulated as if they
were in SRAM.
In the XMEGA variant, the working register file is not mapped into the data address space;
as such, it is not possible to treat any of the XMEGA's working registers as though they were
SRAM. Instead, the I/O registers are mapped into the data address space starting at the very
beginning of the address space. Additionally, the amount of data address space dedicated to
7

Android Bluetooth controlled robot

I/O registers has grown substantially to 4096 bytes (0000 160FFF16). As with previous
generations, however, the fast I/O manipulation instructions can only reach the first 64 I/O
register locations (the first 32 locations for bitwise instructions). Following the I/O registers,
the XMEGA series sets aside a 4096 byte range of the data address space which can be used
optionally for mapping the internal EEPROM to the data address space (1000161FFF16). The
actual SRAM is located after these ranges, starting at 2000.

5.4 Instruction set

Pointer registers X, Y, and Z have addressing capabilities that are different from

each other.

Register locations R0 to R15 have different addressing capabilities than register

locations R16 to R31.

I/O ports 0 to 31 have different addressing capabilities than I/O ports 32 to 63.

CLR affects flags, while SER does not, even though they are complementary

instructions. CLR set all bits to zero and SER sets them to one. (Note that CLR is pseudo-op
for EOR R, R; and SER is short for LDI R,$FF. Math operations such as EOR modify flags
while moves/loads/stores/branches such as LDI do not.)

Accessing read-only data stored in the program memory (flash) requires special

LPM instructions; the flash bus is otherwise reserved for instruction memory.

5.5 MCU speed


The AVR line can normally support clock speeds from 0 to 20 MHz, with some devices
reaching 32 MHz. Lower powered operation usually requires a reduced clock speed. All
recent (Tiny, Mega, and Xmega, but not 90S) AVRs feature an on-chip oscillator, removing
the need for external clocks or resonator circuitry. Some AVRs also have a system clock
prescaler that can divide down the system clock by up to 1024. This prescaler can be
reconfigured by software during run-time, allowing the clock speed to be optimized.
Since all operations (excluding multiplication and 16-bit add/subtract) on registers R0 R31
are single cycle, the AVR can achieve up to 1 MIPS per MHz, i.e. an 8 MHz processor can
achieve up to 8 MIPS. Loads and stores to/from memory take two cycles, branching takes

Android Bluetooth controlled robot

two cycles. Branches in the latest "3-byte PC" parts such as ATmega2560 are one cycle
slower than on previous devices.

5.6 Features
1.

High-performance, Low-power Atmel AVR, 8-bit Microcontroller

2.

Advanced RISC Architecture

a.131 Powerful Instructions Most Single-clock Cycle Execution


b.

32 x 8 General Purpose Working Registers

c.Fully Static Operation


d.

Up to 16 MIPS Throughput at 16 MHz

e.On-chip 2-cycle Multiplier


3.

High Endurance Non-volatile Memory segments

a.16 Kbytes of In-System Self-programmable Flash program memory


b.

512 Bytes EEPROM

c.1 Kbyte Internal SRAM


d.

Write/Erase Cycles: 10,000 Flash/100,000 EEPROM

e.Data retention: 20 years at 85C/100 years at 25C


f. Optional Boot Code Section with Independent Lock Bits
4.

In-System Programming by On-chip Boot Program

5.

True Read-While-Write Operation

a.Programming Lock for Software Security


6.

JTAG (IEEE std. 1149.1 Compliant) Interface

a.Boundary-scan Capabilities According to the JTAG Standard


b.

Extensive On-chip Debug Support

c.Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
7.

Peripheral Features

a.Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes


b.

One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture

8.

Mode

a.Real Time Counter with Separate Oscillator


b.

Four PWM Channels

c.8-channel, 10-bit ADC


9.

8 Single-ended Channels

10.

7 Differential Channels in TQFP Package Only


9

Android Bluetooth controlled robot

11.

2 Differential Channels with Programmable Gain at 1x, 10x, or 200x

a.Byte-oriented Two-wire Serial Interface


b.

Programmable Serial USART

c.Master/Slave SPI Serial Interface


d.

Programmable Watchdog Timer with Separate On-chip Oscillator

e.On-chip Analog Comparator


12.

Special Microcontroller Features

a.Power-on Reset and Programmable Brown-out Detection


b.

Internal Calibrated RC Oscillator

c.External and Internal Interrupt Sources


d.

Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby

13.

and Extended Standby

14.

I/O and Packages

a.32 Programmable I/O Lines


b.

40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF

15.

Operating Voltages

a.2.7V - 5.5V for ATmega16L


b.

4.5V - 5.5V for ATmega16

16.

Speed Grades

a.0 - 8 MHz for ATmega16L


b.

0 - 16 MHz for ATmega16

17.

Power Consumption 1 MHz, 3V, and 25C for ATmega16L

a.Active: 1.1 mA
b.

Idle Mode: 0.35 mA

c.Power-down Mode: < 1 a

10

Android Bluetooth controlled robot

5.7 Pin Configuration


Figure

5.1 Pin Diagram

DESCRIPTION:VCC: Digital supply voltage.


GND: Ground.
I/O Ports (PA0 PA7, PB0 PB7, PC0 PC7, and PD0 PD7): All the ports serve as an
8-bit bi-directional I/O port. Port pins can provide internal pull-up resistors (selected for
each bit). The Port output Buffers have symmetrical drive characteristics with both high sink
and source capability. When pins are used as inputs and are externally pulled low, they will
11

Android Bluetooth controlled robot

source Current if the internal pull-up resistors are activated. The Port pins are tri-stated when
a reset condition becomes active, even if the clock is not running. Apart from this all the
ports have their own alternate functions they will be explained later.
RESET: Reset input. A low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running. The minimum pulse length is 1.5s. Shorter
pulses are not guaranteed to generate a reset.
XTAL1: Input to the inverting Oscillator amplifier and input to the internal clock operating
circuit.
XTAL2: Output from the inverting Oscillator amplifier.
AVCC: AVCC is the supply voltage pin for Port A and the A/D Converter. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter.
AREF: AREF is the analog reference pin for the A/D Converter.
Port A Alternate functions: Port A acts as the input for the ADC.
Port Pin

Alternate Function

PA7

ADC7(ADC input channel 7)

PA6

ADC6(ADC input channel 6)

PA5

ADC5(ADC input channel 5)

PA4

ADC4(ADC input channel 5)

PA3

ADC3(ADC input channel 5)

PA2

ADC2(ADC input channel 5)

PA1

ADC1(ADC input channel 5)

PA0

ADC0(ADC input channel 5)


Table5.1. Alternate Function of Port A

Port B Alternate functions: Port B pins have the alternate functions of SPI interface,
Analog comparator inputs, Timer/Counter external clock input.
12

Android Bluetooth controlled robot

Port Pin

Alternate Function

PB7

SCK(SPI Bus Serial Clock)

PB6

MISO(SPI Bus Master Input/Slave Output)

PB5

MOSI(SPI Bus Master Output/Slave Input)

PB4

SS(SPI Slave Select Input)

PB3

AIN1(Analog Comparator Negative Input)


OC0(Timer/Counter0 Output Compare Match Output )

PB2

AIN0(Analog Comparator Positive Input)INT2(External


Interrupt 2 Input)

PB1

T1(Timer/Counter1 External Counter Input)

PB0

T0(Timer/Counter Input)XCK(USART External Clock


Input/Output)
Table5.2. Alternate Function of Port B

Port C Alternate Functions: Port C pins have the alternate functions of Timer oscillator &
two wire serial interface.
Port Pin

Alternate Function

PC7

TOSC2(Timer Oscillator Pin2)

PC6

TOSC2(Timer Oscillator Pin2)

PC1

SDA(2 wire serial bus data IO line)

PC0

SCL(2 wire serial bus clock line)


Table5.3. Alternate Function of Port C

Port D Alternate Functions: Port D pins have the alternate functions of external interrupts,
USART, Timer match outputs, capture inputs.

13

Android Bluetooth controlled robot

Port Pin

Alternate Function

PD7

OC2(Timer/Counter 2 Output Compare Match Output)

PD6

ICPI(Timer/Counter 1 Input Capture Pin)

PD5

OCIA(Timer/Counter 1 Output Compare A Match Output )

PD4

OCIB(Timer/Counter 1 Output Compare B Match Output)

PD3

INTI(External Interrupt 1 Input)

PD2

INTO(External Interrupt 0 Input)

PD1

TXD(USART Output Pin)

PD0

RXD(USART Input Pin)


Table5.4 Alternet Function of portD

6. BLUETOOTH DRIVER
HC serial Bluetooth products consist of Bluetooth serial interface module and Bluetooth
adapter, such as:

6.1 Bluetooth serial interface module


Industrial level: HC-03, HC-04(HC-04-M, HC-04-S)
14

Android Bluetooth controlled robot

Civil level:

HC-05, HC-06(HC-06-M, HC-06-S)

HC-05-D, HC-06-D (with baseboard, for test and evaluation)

6.2 Bluetooth adapter


HC-M4
HC-M6
This document mainly introduces Bluetooth serial module. Bluetooth serial module is used
for converting serial port to Bluetooth. These modules have two modes: master and slaver
device. The device named after even number is defined to be master or slaver when out of
factory and cant be changed to the other mode. But for the device named after odd number,
users can set the work mode (master or slaver) of the device by AT commands.
HC-04 specifically includes
Master device:
Slave device:

HC-04-M, M=master
HC-04-S, S=slaver

The default situation of HC-04 is slave mode. If you need master mode, please state it
clearly or place an order for HC-O4-M directly.The naming rule of HC-06 is same. When
HC-03 and HC-05 are out of factory, one part of parameters are set for activating the device.
The work mode is not set, since user can set the mode of HC-03, HC-05 as they want. The
main function of Bluetooth serial module is replacing the serial port line, such as:

There are two MCUs want to communicate with each other. One connects to

Bluetooth master device while the other one connects to slave device. Their connection can
be built once the pair is made. This Bluetooth connection is equivalently liked to a serial port
line connection including RXD, TXD signals. And they can use the Bluetooth serial module
to communicate with each other.

When MCU has Bluetooth salve module, it can communicate with Bluetooth

adapter of computers and smart phones. Then there is a virtual communicable serial port line
between MCU and computer or smart phone.

15

Android Bluetooth controlled robot

The Bluetooth devices in the market mostly are salve devices, such as Bluetooth

printer, Bluetooth GPS. So, we can use master module to make pair and communicate with
them. Bluetooth Serial modules operation doesnt need drive, and can communicate with
the other Bluetooth device which has the serial. But communication between two Bluetooth
modules requires at least two conditions:
The communication must be between master and slave.
The password must be correct.

Figure 6. 7 HC-05 Bluetooth model

7. MOTOR DRIVER
The L293 and L293D are quadruple high-current half-H drivers. The L293 is designed to
provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293D
is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to
36 V. Both devices are designed to drive inductive loads such as relays, solenoids, dc and
bipolar stepping motors, as well as other high-current/high-voltage loads in positive-supply
applications.
All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a
Darlington transistor sink and a pseudo- Darlington source. Drivers are enabled in pairs,
16

Android Bluetooth controlled robot

with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an
enable input is high, the associated drivers are enabled, and their outputs are active and in
phase with their inputs. When the enable input is low, those drivers are disabled, and their
outputs are off and in the high-impedance state. With the proper data inputs, each pair of
drivers forms a full-H (or bridge) reversible drive suitable for solenoid or motor
applications.

Figure 7. 8 L293D Motor Driver Model

SOFTWARE
AVR studio:- In this project we are using the AVR studio in which programming is done
with the help of C language. AVR studio programming is used for digital input- output in C.
Each AVR digital I/O port is associated with input output register and it is known as DDRx,
PORTx registers where x represent the port A ,B, C.
Step1: The new project is been selected.

17

Android Bluetooth controlled robot

Step2: AVR GCC is selected in which file is made.

Step3: The micro-controller which has been used is been selected.


18

Android Bluetooth controlled robot

Step4: The code is been written.

Step5: The above code is been compiled and burnt using sinaprog.
The DDRx register is used to configure the pins on the PORTx as input or output pins. Each
pin on the port is independent and thus the entire port does not have to be configured totally
19

Android Bluetooth controlled robot

as an output or input port.when we write 1 in the pin position in DDRx, then it means that
the pin is output pin and if 0 is written in the pin position then it means that the pin is input
pin.
The AVR C code below shows how to configure the pins on the port:
DDRA =0xFF; // Configure PortA as an Output port
DDRB =0x00; //Configure PortB as an Input port
DDRC=0xF0; //Configure first 4 pins on PortC as input pins and the others as output

A bit represents one of two possible states: 1 or 0 which means on/off, set/clear, high/low.
Several bits together represent numerical values in binary, where each bit is one binary digit.
An AVR microcontroller groups 8 bits together to form one byte with the
least Significant Bit (LSB) on the right. Each bit is numbered, starting from 0, at the LSB.
Consider the decimal number 15 for example. When it is represented in the binary format
then we get the value as 00001111.The four significant bits 0,1,2,3 are set.

The decimal number 15 represented in 8 bits


Another example is ,the decimal value 40.When it is represented in the binary format then
its value will be 00101000.Here bits 3 and 5 are set.

The decimal number 40 represented in 8 bits


Numerical values in a C program for an AVR microcontroller may be defined using a
decimal, hexadecimal, or binary notation depending on the context and the programmers
preference. A 20exadecimal number is defined using the 0x prefix and a binary number is
defined using the
0b prefix.
The following C code shows 3 ways in which a variable might be initialized to the decimal
value of 15.
15 - /*decimal*/
0x0F- /*hexadecimal*/
20

Android Bluetooth controlled robot

0b0001111- /*binary*/
Example:
Write a program to be downloaded to the Atmega16 microcontroller which continuously
read the logic values on PortB and write them to PortC.
Solution:
The program below written in AVR Studio 4 accomplishes the task that was asked above.
Here several rules should be following:
1.
The header file <avr/io.h> must be included in order to use the name of the ports.
2.
The port must be configure before they are used. The first two lines in the main()
function of the program are for configuration.
3.
Once the ports are configured the we can write or read from them.
4.
The use of the While(1) loop allows for the continuous read and write operation.
#include<avr/io.h>
int main(){
DDRB =0x00;

//configure portB as input

DDRB= 0xFF; // configure portC as output


While (1){
PORTC=PINB;
}
Return0 ;
}
}
Here there are some other header files are used for running of each component used in the
project model. They are given below:# include<avr/io.h>

// used for the name of the project

#include<util/delay.h>

// used if any delay occurred in the program

# include<avr/adc.h>

// for converting analog to digital

21

Android Bluetooth controlled robot

When program writing is complete, then we burn the microcontroller by using Sinaprog
Hex. Sinaprog is applicable when AVR studio software is used for coding of microcontroller.
Programming or burning a microcontroller means to transfer the program from the compiler
to the memory of the microcontroller. A compiler is a software which provides an
environment to write, test and debug a program for the microcontroller. The program for a
microcontroller is generally written in C or assembly language. Finally the compiler
generates a hex file which contains the machine language instruction understandable by a
microcontroller. It is the content of this hex file which is transferred to the memory of the
microcontroller. Once a program is transferred or written in the memory of the
microcontroller, it then works in accordance with the program.

Steps for burning a microcontroller-

Step1:- First install the Sinaprog Hex.


Step2:-Open the Sinaprog Software.

22

Android Bluetooth controlled robot

Step3:- From the Hex File section browse the .hex file of the project you have Built.

Step4:- From Flash section click on Program button and wait for some time till it finishes
programming. When it displays the message Programming Flash OK your controller is
ready to work as per your program.

23

Android Bluetooth controlled robot

24

Android Bluetooth controlled robot

PROGRAM
#include<avr/io.h>
#include<util/delay.h>
#include<avr/usart.h>
void main()
{
DDRB=0b11111111;

// 1> for o/p

usart_init();
PORTB=0b00000000;
while(1)
{
unsigned char x=usart_data_receive();

if((x=='A')||(x=='f'))
{
PORTB=0b00001010;

//forward

}
else if((x=='B')||(x=='b'))
{
PORTB=0b00000101;

//backward;

else if((x=='D')||(x=='r'))
{
PORTB=0b00000010;

//right

}
else if((x=='C')||(x=='l'))
25

Android Bluetooth controlled robot

{
PORTB=0b00001000;

//left

}
else if((x=='E')||(x=='s'))
{
PORTB=0b00001111;

//stop

}
else if(x=='G')
{
PORTB=0b00001001;

//360

else if(x=='F')
{
PORTB=0b00000110;

//-360

}
else
;}
}

26

Android Bluetooth controlled robot

CONCLUSION
We developed the remote buttons in the android app by which we can control the robot
motion with them. And in which we use Bluetooth communication to interface controller
and android. Controller can be interfaced to the Bluetooth module though UART protocol.
According to commands received from android the robot motion can be controlled. The
consistent output of a robotic system along with quality and repeatability are unmatched.
Pick and Place robots can be reprogrammable and tooling can be interchanged to provide for
multiple applications. The project is designed to control a robotic vehicle using an android
application. Bluetooth device is interfaced to the control unit on the robot for sensing the
signals transmitted by the android application. This data is conveyed to the control unit
which moves the robot as desired. An 8051 series microcontroller is used in this project as
control device.

27

Android Bluetooth controlled robot

REFERENCES
[1]

http://www.emtronizian.co.in/pdf/avrbasic.pdf

[2]

http://www.engr.sjsu.edu/bjfurman/courses/ME106/ME106pdf/intro-atmel.pdf

[3]

http://www.engr.sjsu.edu/~wdu/ME106Spring2010/LectureNotes/Si

mulatorTutorial.pdf
[4]

http://robotika.yweb.sk/skola/AVR/programing%20AVR%20by

%20BIBIN%20JOHN.pdf
[5]

http://engneeringgarage.yweb.ke/hgfjk/android/bluetooth%34robot%gousan

%21birth.pdf

28

You might also like