Introduction: GCD Bluetooth Car

This is the project I made during Grand Challenge Design in 2017. The coding here is slightly different than what I used, but serves the same purpose.

Step 1: Acquire Materials

You will need:

1) Arduino

1) Holder for 4 batteries

1) Small breadboard

2) DC Servos for wheels

1) Bluetooth receiver/ transmitter (HC-05)

2) Transistors (tip120)

17) male-to-male jumper wires

4) Resistors (1000 ohms)

& a base for your car. I cut wood to from a two part base, but something as simple as a shoe box would work just as well.

Step 2: Program Arduino

This step is tricky to do on your own. Luckily, it has been done many times before, and this code can be taken from https://gist.github.com/ruisantos16/5023583#file-...

.

/*
* created by Rui Santos, http://randomnerdtutorials.com

* Control 2 DC motors with Smartphone via bluetooth

*/

int motor1Pin1 = 3; // pin 2 on L293D IC

int motor1Pin2 = 4; // pin 7 on L293D IC

int enable1Pin = 6; // pin 1 on L293D IC

int motor2Pin1 = 8; // pin 10 on L293D IC

int motor2Pin2 = 9; // pin 15 on L293D IC

int enable2Pin = 11; // pin 9 on L293D IC

int state;

int flag=0; //makes sure that the serial only prints once the state

int stateStop=0;

void setup() {

// sets the pins as outputs:

pinMode(motor1Pin1, OUTPUT);

pinMode(motor1Pin2, OUTPUT);

pinMode(enable1Pin, OUTPUT);

pinMode(motor2Pin1, OUTPUT);

pinMode(motor2Pin2, OUTPUT);

pinMode(enable2Pin, OUTPUT);

// sets enable1Pin and enable2Pin high so that motor can turn on:

digitalWrite(enable1Pin, HIGH);

digitalWrite(enable2Pin, HIGH);

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

}

void loop() {

//if some date is sent, reads it and saves in state

if(Serial.available() > 0){

state = Serial.read();

flag=0;

}

// if the state is 'F' the DC motor will go forward

if (state == 'F') {

digitalWrite(motor1Pin1, HIGH);

digitalWrite(motor1Pin2, LOW);

digitalWrite(motor2Pin1, LOW);

digitalWrite(motor2Pin2, HIGH);

if(flag == 0){

Serial.println("Go Forward!");

flag=1;

}

}

// if the state is 'R' the motor will turn left

else if (state == 'R') {

digitalWrite(motor1Pin1, HIGH);

digitalWrite(motor1Pin2, LOW);

digitalWrite(motor2Pin1, LOW);

digitalWrite(motor2Pin2, LOW);

if(flag == 0){

Serial.println("Turn LEFT");

flag=1;

}

delay(1500);

state=3;

stateStop=1;

}

// if the state is 'S' the motor will Stop

else if (state == 'S' || stateStop == 1) {

digitalWrite(motor1Pin1, LOW);

digitalWrite(motor1Pin2, LOW);

digitalWrite(motor2Pin1, LOW);

digitalWrite(motor2Pin2, LOW);

if(flag == 0){

Serial.println("STOP!");

flag=1;

}

stateStop=0;

}

// if the state is 'L' the motor will turn right

else if (state == 'L') {

digitalWrite(motor1Pin1, LOW);

digitalWrite(motor1Pin2, LOW);

digitalWrite(motor2Pin1, LOW);

digitalWrite(motor2Pin2, HIGH);

if(flag == 0){

Serial.println("Turn RIGHT");

flag=1;

}

delay(1500);

state=3;

stateStop=1;

}

// if the state is 'B' the motor will Reverse

else if (state == 'B') {

digitalWrite(motor1Pin1, LOW);

digitalWrite(motor1Pin2, HIGH);

digitalWrite(motor2Pin1, HIGH);

digitalWrite(motor2Pin2, LOW);

if(flag == 0){

Serial.println("Reverse!");

flag=1;

}

}

}

Step 3: Hardware

Set up the breadboard as seen in the image. Then, attach the rest of the components to the corresponding places on the breadboard.

Step 4: Wheels and Driving

First, you must attach the wheels to the body of your car. I used Velcro strips, but hot glue or even small screws work as well. For awhile, I even just tied them on with pipe cleaners! Then, you must decide on a back tire. Ideally, this would be a free-spinning wheel or marble in a socket for minimal traction, but other, simpler options are available. I used a wire cap, Sharpie, and a screw with paper folded over the end while building and testing my car. All you really need is something that will slide smoothly along the ground.

In order to drive your car, you simply need to download the app BlueTerm on an android device, connect to HC-05 both on your phone and in the app, and begin clicking F, R, L, S, and B.

Step 5: Troubleshooting

Often, there will be initial issues when you attempt to drive your car. There are many components in this project, and they can be finicky at times. Here is a list of some common errors and solutions.

No response from car:

Make sure bluetooth module is detached when loading code to Arduino.

Tx on the BT module should be connect to Rx on the Arduino and vice versa

Double-check wiring and power to Arduino & wheels

Make sure the BT module is connected on the phone and in BlueTerm.

Car does not drive properly:

The wheels may be wired incorrectly. Try reversing the wiring to the wheels or switching the wires around to the other wheel.

The wires may be connected to the wrong ports on the Arduino. Double check the code to ensure proper attachment.