Controlling a robot car wirelessly is very interesting for a beginner or new in the robotics field. But the main question is how to make a robot car?. In this tutorial, we will cover how to make an android controlled robot car.
For this project, we have two sections. One is transmitter and second is a receiver. Here transmitter is an android phone and connected with the receiver robot using the bluetooth connection. Android phone already has inbuilt bluetooth. To connect to this android bluetooth, we are using one bluetooth module to the receiver side. We pair both the bluetooth module.
After pairing the android phone and robot, we use android application to control the receiver robot. We are using the Bluetooth Controller app to control the android robot. When a forward button is pressed ‘A’ is sent via this android bluetooth to the receiver bluetooth module. Same with other buttons. At the receiver, we write the code to accept the character ‘A’ and move the robot forward. Each button assigned a value, which is known by the receiver. And receiver takes action according to the value received.
Before using the app, we need to configure the application.
How to Connect Bluetooth Module to the AVR
We have used HC-05 bluetooth module for this project. This module is connected with the atmega8. Both the module is connected using the serial communication. This android bluetooth robot using the serial communication to communicate with the bluetooth module and AVR ATmega8.
For an understanding of the serial communication, you can visit our tutorial Arduino Serial Communication Tutorial
The hc-05 bluetooth module has six pins Vcc, GND, RX, TX, Key and State. By default, it comes as a slave device means it will only receive the signal can’t initiate a connection.But if you want to send something from this module then we need to change it to the master mode by applying some AT commands. If we are connecting HC 05 with the android phone we simply use it in Slave Mode. The default transfer rate will be 9600 baud rate. The HC-05 module has a factory set pin “1234” which is used for pairing to the phone.
HC 05 Bluetooth Pinout
- Protocol: Bluetooth Specification v2.0+EDR
- Frequency: 2.4GHz ISM band
- Modulation: GFSK
- Emission power: ≤4dBm, Class 2
- Speed: Asynchronous: 2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps
- Sensitivity: ≤-84dBm at 0.1% BER
- Power supply: +3.3VDC 50mA
- Security: Authentication and encryption
- Working temperature: -20 ~ +75 Centigrade
How to Configure Bluetooth Controller App
You can see easily that all the button is blank and we can give a text to this button according to our project.
So press button “SET KEYS”
A new window will open:
Key Name: Forward, Back, Left, Right and Stop => This is Button Text
Key Value: => A, B, C, D and E respectively, Now press OK.
Now connect the bluetooth module as shown above and then supply it. Pair the HC-05 device with the mobile. It is just like we pair the other mobiles. The passkey is “1234”. Once paired we can find it from the bluetooth controller app by pressing the button “SCAN”.
And it’s Done! Now we write the code to AVR that will control the robot by accepting the value A, B, C, D, and E.
Bluetooth Controlled Robot Circuit
Bluetooth Controlled Robot AVR Microcontroller Code
//This function is used to initialize the USART
//at a given UBRR value
void USARTInit(uint16_t ubrr_value)
//Set Baud rate
UBRRL = ubrr_value;
UBRRH = (ubrr_value>>8);
//Enable The receiver and transmitter
//Wait until a data is available
while(!(UCSRA & (1<<RXC)))
void USARTWriteChar(char data)
while(!(UCSRA & (1<<UDRE)))
DDRB=0b11111111;//Motor at PORTB
case ‘A’:PORTB=0b00001010; //Forward
case ‘C’:PORTB=0b00001001; //Left
case ‘D’:PORTB=0b00000110; //Right
case ‘B’:PORTB=0b00000101; //Back
case ‘E’:PORTB=0b00001111; //Stop