Let’s make a wireless Arduino Controlled Bluetooth car.
Contents:
- Introduction
- Materials Required
- Integrating the Chassis kit
- Arduino Code
- The Circuit and it’s Explanation
- Configuring the Mobile Application
- The Final Run
1. Introduction
Hey everyone, today we are going to make an Arduino controlled Bluetooth Car. We will use the mobile phone’s Bluetooth to control the car. We will use the normal geared DC motors and the chassis. Let’s start with collecting the hardware items.
2. Materials Required
- Arduino board (Nano/Uno)
- L298N motor driver
- RC Car chassis
- 4 Geared DC motors
- HC-05 (Bluetooth module)
- Jumper wires
- LED
- Power Source (>=7.4V-1000mAh)
3. Integrating the Chassis Kit
The chassis kit includes 4 wheels, 4 geared DC motors, the body, and the screws. These components come along the kit only. Firstly, fit all the DC motors and then fit the wheels properly. Don’t close the upper lid (if present) now, as you need to fit the whole electronics in it. After going through the subsequent sections and completing the car, you can fit the upper lid (if present) of your Bluetooth Car. Refer to the image below.
4. Arduino Code
In the code, we need to set 5 digital pins as output. After receiving the command from the mobile app, we will make some particular pins ‘HIGH’ to execute the command, say to move ahead. The car can perform mainly four functions, to move ahead, behind, left or right. This is how the final code will look like.
char t;
void setup() {
pinMode(13,OUTPUT); //left motors forward
pinMode(12,OUTPUT); //left motors reverse
pinMode(11,OUTPUT); //right motors forward
pinMode(10,OUTPUT); //right motors reverse
pinMode(9,OUTPUT); //Led
Serial.begin(9600);
}
void loop() {
if(Serial.available()){
t = Serial.read();
Serial.println(t);
}
if(t == 'F'){ //move forward(all motors rotate in forward direction)
digitalWrite(13,HIGH);
digitalWrite(11,HIGH);
}
else if(t == 'B'){ //move reverse (all motors rotate in reverse direction)
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
}
else if(t == 'L'){ //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)
digitalWrite(11,HIGH);
}
else if(t == 'R'){ //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)
digitalWrite(13,HIGH);
}
else if(t == 'W'){ //turn led on or off)
digitalWrite(9,HIGH);
}
else if(t == 'w'){
digitalWrite(9,LOW);
}
else if(t == 'S'){ //STOP (all motors stop)
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
}
delay(100);
}
5. Circuit and Explanation
Consider the circuit shown below.
Now, take the controller in which you have uploaded the code given above. Then, first of all, connect the D10-D13 pins of your microcontroller to the 4 input pins of the motor driver as shown in the figure. The controller gives the commands to run the motors via these pins only. Connect the two motors of each side to the output pins of the driver as shown. Connect the power supplies carefully. The Vcc of the Bluetooth module is connected to that of the controller. You can either use a simple switch or can connect the battery at the end of the setup. Try to confine the electronics within the chassis.
Make sure that all the connections are tight enough. After fitting the components, close the upper Lid in case your chassis consists of it. I hope you can see your finished car by now.
6. Configuring the Mobile Application
By now, we have completed our car. But how the car will move? For that, we need to pass the signals from a mobile app. You can develop your own app or download the several Apps present in the play store. After downloading the app, open the Bluetooth of your device, and search the available devices. Connect it with your car’s Bluetooth and enter the passkey (probably 0000 or 1234). The blinking rate of the HC-05 module should change which shows that the device has been connected now. Now open the settings of your app. In that, make sure that the commands which pass when you press a button are compatible with the code. For example, the forward button of the app should pass ‘F’ as that only moves our car forward. Check the other buttons too.
7. Final run
I hope you were able to complete the project. Congratulations! Anytime you want to run the car, switch on the button, pair with the app, and enjoy it. If you faced any issues, feel free to write it in the comment section.