Interfacing android with pic microcontroller via Bluetooth

By | January 21, 2014

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. Then 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 come to our mind 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 “Interfacing android with pic microcontroller via Bluetooth”


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.

68 thoughts on “Interfacing android with pic microcontroller via Bluetooth

  1. Ian Westbury

    Hi Subham. Thanks for posting that. I have a car that I can successfully control with a laptop via Bluetooth. The PIC is a 16F628A and has all of the I/O I need for UART, motor outputs, a servo for steering and even an encoder read interface for speed. I made a VB interface for the GUI and now I want to make one in Android. I am interested in your comment “I download Bluetooth control apps from Google play store”. Was this an “off the shelf” option or did you write it yourself?

    Thanks, and keep up the good work.

    Reply
    1. subham1981 Post author

      Thanks Ian for your comment. Yes you can make your android apps for your own just only you have to send ascii code for controlling the output device via micro controller.

      Reply
  2. boufedah badissi

    goodafternoon;
    please if its possible to send me the program with details, i’m not understanding, and i want to understand beacuse i’ve project: transfer temperature from sensor ds1775 to pc via bluetooth with microcontroler 16f877.
    cordialement

    Reply
    1. subham1981 Post author

      WHAT IS NOT UNDERSTAND PLEASE WRITE HERE? EVERYTHING WRITTEN HERE WITH C CODE.
      SUBHAM

      Reply
  3. Ashwani

    which UART DB9 coonector model you have used in proteus,plz explain or tell the model no.
    my email id is “akgarg007@gmail.com”

    Reply
  4. Ashwani

    hi,the code is giving so much error,when i add the device line at starting of the code like dat: #include
    ,plz give the solution,or send the c code file to my email id (akgarg007@gmail.com)
    Your help will be appreciable
    Thanks
    Ashwani

    Reply
    1. Subham Dutta Post author

      hi code is fine you just concentration on when you copy or paste then you have to change invited comma because when you copy paste some format of character not supported in Microc find and changed those it will running no problem.

      Reply
  5. Ajay

    Hello Sir. I am just wondering if this code was created on MPLAB or MicroC or any other software? I don’t think I can use this code for MPLAB because it doesn’t even have a header file.

    Reply
  6. zein

    i am doing android based home automation project can u help me please? 10q.

    Reply
  7. zein

    10q very much, i wonder if u give me the schematic with source code to make on/off light or any home appliance by using phone/android.

    Reply
  8. zein

    i have tried the door lock with sms alert project, when i compile it there is no error but the simulation on proteus will be reset automaticaly it says reset by watchdog timer.what is the problem.

    Reply
  9. Nachiket Sakinal

    Hi,
    How much program memory is required for this Bluetooth application ?

    Reply
  10. AJAY

    Is there a way to convert this code to MPLAB code? I don’t know how to open peripherals etc in MPLAB like for example for ADC OPENADC(ADC_OFF etc etc ..)

    Reply
  11. Lethula

    Hi
    I’m transmitting keys pressed on a 4×4 keypad using pic16f877a, i’m having a problem with the Bluetooth transnissiion.
    i’m using the HC 06 Buetooth Module

    Reply
  12. zein

    hi Subham Dutta can u give me c code to read sms by interfacing mobile with pic please! help me please! 10q

    Reply
  13. ramcharan bvs

    i am trying to control a stepper motor connected to pic16f877a by android phone via bluetooth.
    i am trying to communicate with pic sending and receiving characters. Simulation in proteus is perfect but when it comes to actual implementation, its not working. Some are correctand some char are wrong.instead of a i am getting y , r instead of b, s inst of c, ~ inst of x and remaining are almost same. Please help me asap..please..

    please help me to program my pic so that if i send s15 it should decode ‘s’ and understand its ‘s’.. pls help

    Reply
  14. Rodolfo

    hi, i really interesting in make something like you have done.

    i want to start programing something to interact between Android cellphone and PIC microcontroller,

    i have done alot of programing before with the PIC 16f877a and 16f628, but i have never usea any bluetooth device or comunication.

    if you can send me more infromation beside what you have put here, will really help.

    my email : rodolfo_vz@hotmail.com

    thanks , sorry for my bad english , i’m from mexico.

    regards

    Reply
  15. Patel

    I am very much interested in Android-PIC projects.Can you send me the Circuit Diagram of this project and …..It will be Very Helpful.Also specify the Bluetooth module used..
    Email id : jigu1997@gmail.com
    Thank You………

    Reply
  16. Abhilash

    How the bluetooth module is interface with pic?..
    protocol for bluetooth…..

    Reply
  17. Aaddi

    Hey hi
    Can u mail me the proteus simulation.
    i want to transmit sine wave via pic to my android mobile
    can u give any suggestion.
    my mail is adeeb550@gmail.com

    Reply
  18. shams

    sir plz can u tell me that what is “i” in above code?sir plz can u send me proteus simulation.

    Reply
  19. Rahul gour

    Good morning sir..
    I am a regular visitor in ur website from past so many years. I am intrested in your pilot car project but i am finding difficulties in circuit diagram and pcb designing so please provide me the useful information regarding this project soon.
    Thanks . . . .

    Reply
  20. vishal

    sir i am interfacing temperature IC and pressure IC with PIC 16F877A and displayed these parameter information on LCD. Now if i want to display these information on mobile using bluetooth. what are the step i have to follow.which type 0f programming i have to do for displaying the data on mobile.?

    Reply
  21. rex

    Hi sir. can you send me that codes of your android . if it is okay with you
    thanks by the way.

    Reply
  22. raja

    sir i had a problem how to command the Xbee who receive a signal from android to light a 8 LED using PIC16f877a.

    what should i prefer sir to do this project?
    ASAP
    rajakamalafifi@gmail.com
    Thanks You sir

    Reply
  23. Abhijit

    Hi Subham,
    Subho Bijaya to you and your family !

    I have few doubt. Can you please clarify.

    1. do you have complete circuit diagram. If yes then please post the same or mail me (abhijit2683@gmail.com).
    2. In the C code given above, PWM1_init() function is user defined function or it is inbuilt.

    Thanks & Regards,
    Abhijit
    9831493210

    Reply
  24. Josh Inya

    For the bluetooth module, is it just the RX-TX pins on PIC16F877 to the COM port connection you describe here (http://www.nbcafe.in/serial-communication-with-pic-16f877-using-uart/) and then using a USB BT dongle on your computer and having the computer program take in the bluetooth signal from the phone? Is it possible to use a bluetooth chip (http://www.st.com/web/en/resource/technical/document/datasheet/DM00048919.pdf) to directly connect to the phone?

    Thanks Subham!

    Reply
  25. Paul

    Good day sir!
    Do you have circuit diagram of bluetooth and microcontroller? can you send me sir? here’s my e.add. “azrat000@gmail.com” tnx sir!!

    Reply
  26. Chaitanya Kumar

    Everything is clear about your project expect that bluetooth module which you are using. I am stuck with my project in the same are. I need some bluetooth module which sends digital data from a micro controller through bluetooth. If you suggest some it would really help. Thanks

    Reply
  27. Sachin

    I want to connect my laptop Bluetooth adapter to my android Bluetooth for simulation of DC motor. I am simulating it using Proteus software. What needs to be done. Please guide…

    Reply
  28. haikal

    nice project u have here. .
    can you help me here. .im trying to do ur project. .i copy ur code and paste it on mikroC. .

    can i have ur proteus schematic. .i dunno if servo motor setting is wrong or bluetooth problem. .but i cant control servomotor through my android phone like u did. .

    my email is bajrai92@gmail.com

    Reply
  29. rommel

    hey guys,, will you plz send me the code for android application to pair with the pic thank you

    Reply
  30. Zishan

    Can this be implemented with arduino uno and if possible please help me in this project I m making a robowar bot please help can it be controlled via Bluetooth

    Reply
  31. palak

    i need program or Code for interfacing of microcontroller with bluetooth module

    Reply
  32. rahul kumar

    hi shubham I am doing this project would you send me the schematic n other details of the the project and the code u have given will it be directly compiled in mickro c or I need to add header file as I have worked on mplab for programming pic 18f n 24f . my email I’d is rahul_kumar938@yahoo.com

    Reply
  33. palak

    hi. i am doing project in final year – wireless speed control of Dc motor using microcontroller and bluetooth module using Android app.
    so plz can u help in programming.?
    how to programming or interfacing in microcontroller (philips ) with bluetooth module Hc-06 or HC-05 ? can u give me that program in c or assembly language. plz help me.
    email- ariwalapalak@gmail.com

    Reply
  34. sayed

    respected sir i am i want to do “controlling home appliance by Bluetooth android app” plz help on this project plzzzz sir…….. my mail is smchagan415@gmail.com plz share your knowledge with me plzzz….

    Reply
  35. vaishali masal

    Hi, I want to implement this project using Simulator. Pls suggest me what software is needed . If possible mail me to masal.vaishali18@gmail.com plz help me sir. OR if you have project which are completely software base especially in MATLAB or other also fine.

    Reply
  36. sri

    Hai I am planning to develop my own app to interface via the bluetooth module to the robot. Do you have any idea how to interface the app with the PIC microcontroller?

    Reply
  37. lama

    Hi … I am developing a project to control car direction by bluetooth using PIC …can you help me by the basic circuit diagram of this project

    Reply
  38. asif

    sir, i am new in this project…. can u please give me the circuit design of this project? n i am having a problem connecting this app to my pc bluetooth… um running windows 8.1…

    Reply
  39. Noureldien

    hi shubham I am doing a similar project. would you send me the schematic and other details of the project. i am also trying to control 4 motors through my phone so it would be a great help if u can send me ur project and schematic plus any other sources about building my own Bluetooth module(Hardware) i mean.

    My email: nour.el-dien@hotmail.com

    thanks alot in advance

    Best Regards,
    Nour

    Reply
  40. Himanshu Gangwar

    hey, i want to make a project on home automation using pic16f877a and bluetooth module. Would u please help me out by sending the circuit diagram to assemble hardware. i have already developed an android app as i belong to cse background. thankyou

    Reply
  41. chathun

    Hi Sir,
    Im an undergraduate student . currently doing a project on home automation can you please send me the Proteus file and c code
    Thank you

    Reply



Leave a Reply

Your email address will not be published. Required fields are marked *