Interfacing android with pic microcontroller via Bluetooth

To forward our first step in the field of wireless communication by interfacing android with pic microcontroller via Bluetooth open lots of way to work on. Once we can send and receive data between a microcontroller and android mobile then use of android mobile we can control other peripheral device attach with microcontroller, very easily. By interfacing android with pic microcontroller via Bluetooth I did my project “Auto Pilot Car”.

Project Objective:

The main objective of my project is to control steering of a car, blow horn, On/Off head light of a car. That means complete auto pilot car can be produce by implementing Interfacing android with pic microcontroller via Bluetooth. Now see the block diagram of my project in bellow

 

Interfacing android with pic microcontroller via Bluetooth

To complete my project interfacing android with pic microcontroller via Bluetooth (Auto pilot car), I used

1>     Android Mobile

2>     Microcontroller PIC16F877

3>     Servo Motor

4>     LED

5>     Buzzer

6>     Bluetooth module

7>     Android apps “Blue control”

 Bluetooth connectivity with Microcontroller:

Now it is another important question that how to connect Bluetooth Module with microcontroller ?

Answer is you have to connect Bluetooth module with UART port like we connect comports. If you have any confusion on “How to interface UART port with microcontroller?“ see my previous post “Serial communication with Pic 16f877 using UART”. In bellow you will find simple block diagram of interfacing Bluetooth module with microcontroller.

pic16f877

Project Description:

In my project interfacing android with pic microcontroller via Bluetooth “Auto Pilot Car” I used servo motor as a Steering of a car, Led as a head light of a car, Buzzer as a horn. Now in my android mobile I download Bluetooth control apps from google play store. From this apps you can send some character like “a;b;c;d;e;f;g;h;U;D;L;R. Using This facility I write my program accordingly to control the total system.


 In bellow you will find the code to run my project

Embedded C Code
// Name : Interfacing android with pic microcontroller via Bluetooth
// Author : Subham Dutta
// Date : 21-01-14
// Website : www.nbcafe.in
unsigned int uart_rd;
main(){
int i;
trisb=0;
portb=0;
PWM1_Init(500);
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read();
UART1_Write(uart_rd);
}
if (uart_rd == ‘a’){
i=21;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘b’){
i=42;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘c’){
i=63;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘d’){
portb=0b00000010;
}if (uart_rd == ‘e’){
i=165;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘f’){
i=187;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘g’){
i=207;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘h’){
portb=0b00000000;}
if (uart_rd == ‘R’){
i=255;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘L’){
i=0;
PWM1_Set_Duty(i);
PWM1_Start();
}
if (uart_rd == ‘C’){
portb=0b00000001;
delay_ms(10);
portb=0b00000000;
PWM1_Start();
}
}
}

And see the video for simulation of my project in Proteus.