Introduction: Arduino Bluetooth Car
it will take about half an hour to make it it's quite simple as you think
you can also make it by following steps given below and make have fun it's give me create joy when I finally made it .
now it's your turn to make it.
just follow the steps given under description
Step 1: Requirements
Bluetooth module hc 05
4wd shield (adafruit)
Jumper wires
Two 9v battery (1. arduino board
2. external power supply to sheild )
Battery cap with 9v pin jack
Step 2: Connection
Step 3: Coding
//*** 1- Documentation
//This program is used to control a robot car using a app that communicates with Arduino trough a bluetooth module
#include <AFMotor.h>
//creates two objects to control the terminal 3 and 4 of motor shield
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);
char command;
void setup()
{
Serial.begin(9600); //Set the baud rate to your Bluetooth module.
}
void loop(){
if(Serial.available() > 0){
command = Serial.read();
Stop(); //initialize with motors stoped
//Change pin mode only if new command is different from previous.
//Serial.println(command);
switch(command){
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255);
motor1.run(BACKWARD); //rotate the motor counterclockwise
motor2.setSpeed(255);
motor2.run(BACKWARD); //rotate the motor counterclockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(0);
motor2.run(RELEASE); //turn motor2 off
}
void right()
{
motor1.setSpeed(0);
motor1.run(RELEASE); //turn motor1 off
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
}
void Stop()
{
motor1.setSpeed(0);
motor2.run(RELEASE); //turn motor1 off
motor2.setSpeed(0);
motor2.run(RELEASE); //turn motor2 off
}
Step 4: Uploading
Step 5: Power Supply
remove the power jumper shown in the figure.
Step 6: Install App
open the app
it ask for permission turn on Bluetooth allow it
the first time password is 1234 or 0000
then click on gear shown in the app now "choose connect to car"
the red button blinking in the app turn to green
now you are connected to your car play with it and enjoy your project.
thank you for watching this instruction
![Microcontroller Contest 2017](https://content.instructables.com/FFZ/8Z2D/IYOQE7ZQ/FFZ8Z2DIYOQE7ZQ.jpg?auto=webp&frame=1&width=320)
Participated in the
Microcontroller Contest 2017