Bluetooth Controlled Car Using Arduino Uno.
Material Required:
Material Quantity
Arduino Uno 1
12V DC Motor /BO motor 2
Jumper cables 15
HC-05 Bluetooth Module 1
Breadboard 1
Breadboard 1
This tutorial will teach you how to create your own Bluetooth controlled car. So let’s get started.
This will be a Bluetooth controlled car so for this project we will be using HC-05 Bluetooth module to receive the controlling data packets.
We will also need an android app which will be sending the controlling data packets to the Bluetooth module. We will use a third party application (https://play.google.com/store/apps/details?id=com.broxcode.arduinobluetoothfree&hl=en to download) for this purpose.
Let's build the hardware (Body of the car)
The car which we are building for this project will be a dual motor car. Two 12 v 200 rpm DC or BO motors. You can use a readymade chassis.
Circuit
Now let us build the circuit.
CODE:
Here we will use the direction of rotation of motors to control the direction of the car. Forward - Both motors move in forward direction.
Backward - Both motors move in backward direction.
Left - Left motor moves backwards and right motor moves forward. Right - Left motor moves forwards and right motor moves backward. Stop - Both motors stop
Tested Programming Code: #include <AFMotor.h> AF_DCMotor motor1(1); //motor1 is the left motor AF_DCMotor motor2(2); //motor2 is the right motor int val; void setup() { Serial.begin(9600); motor1.setSpeed(255); //motor speed is set motor2.setSpeed(255); Stop(); } void loop() { bt=Serial.read(); if(val=='1') //when the bluetooth module recieves 1 the car moves forward { forward(); }
if(val=='2') //when the bluetooth module recieves 2 the car moves backward { backward(); } if(val=='3') //when the bluetooth module recieves 3 the car moves left { left(); } if(val=='4') //when the bluetooth module recieves 4 the car moves right { right(); } if(val=='5') //when the bluetooth module recieves 5 the car stops { Stop(); } } void forward() { motor1.run(FORWARD); motor2.run(FORWARD); }
void backward()
{
motor1.run(BACKWARD); motor2.run(BACKWARD);
}
void left()
{
motor1.run(BACKWARD); motor2.run(FORWARD);
}
void right()
{
motor1.run(FORWARD); motor2.run(BACKWARD);
}
void Stop()
{
motor1.run(RELEASE); motor2.run(RELEASE);
}
Precautions:
1. Double check the connections before powering on the circuit.
2. Don’t use loose jumper cables.
3. Check whether proper board is selected from Arduino IDE.
4. Ensure proper placement of Bluetooth and Motor driver for correct working.
5. Don’t lose hope if it does not run properly for the first time, try again.