Introduction: Remote Control Car With Arduino and Bluetooth

This project consists in making a remote control car using a bluetooth connection. This car is meant to be used in a balloon popping competition against other similar cars. The wireless connection is achieved by using a bluetooth module that's connected to the Arduino and is controlled with an app for Android. This app can be made using different online programs, in our case we will be using the MIT App Inventor. The app serves as a controller that can control the direction in which the car moves. This app also controls the servo motor in which we adapted our weapon for popping other teams' balloons. The Adafruit motor Shield needs to be used together with the Arduino in order to move the DC motors that work as the car's wheels.

Step 1: Materials

The materials that are going to be needed in order to construct the car are:

  1. Arduino (with the Arduino software installed)
  2. Adafruit motor shield
  3. DC motors with wheels adapted to them
  4. External battery for the Arduino (with two slots since it will be used to power both the Arduino and Adafruit.
  5. Bluetooth module
  6. Medium-density fibreboard (MDF)
  7. Android device
  8. Cables to connect the wheels and servomotor to the Adafruit motor shield
  9. Wooden sticks or anything similar
  10. Extras: glue, adhesive tape, or any other material to stick the components to the car's chassis

Additional to this, you may also use other materials in order to personalize your car.

Step 2: Step 1: Making the Chassis

The chassis will be the main body of the car. Every element has to be glued to it so you want to make sure that it has an adequate size. The chassis of the car needs to be designed using a Corel software, it can be either Corel Draw or SolidWorks. In this case, it is going to be designed using SolidWorks. The chassis will be made out of MDF and the easiest way to cut it is using a laser cutter. You will need to save your design with the .DXF extension (which stands for 3D object) in order to print it using the laser cutter. The finished chassis is shown in the next picture. You will have to print it twice. The first one will be used as the base. Here you will stick all the main components: Arduino, DC motors, and the battery. The second one will be used as a protection that will go on top of this first one. The servomotor will be glued to the second design too.

Step 3: Step 2: Creating the Bluetooth App.

The recommended software in order to do this is the MIT App inventor. It is user friendly and works fine once it's finished. The following sequence is recommended for designing your app:

  1. Go to http://appinventor.mit.edu/explore/ and create an account
  2. Once you have your account you can start creating your app. Click on projects, and then on "Start new project".
  3. First, you should create the interface of your app. You can follow the design included in this Instructable, however, you can make it according to your own preference. Whatever design you may use, you need to include the following buttons: Attack (to move your weapon), forward, left, stop, right, reverse. You also need to include a list picker with the name "connect" in order to choose the bluetooth device from your car to connect to it.
  4. On the left part of the design window you will find a section with the name "Palette" then a menu that's called "User interface" here you will find all of the options that you can add to your design. In this case you will only be using: button, list picker, and labels. You may also want to use images.
  5. You can now start dragging the elements that you'll be using to the part where it says "Viewer". You can arrange your buttons anyway you want to. It is recommended that you rename your buttons in order to make programming easier. On the "components menu" search for an specific button, then click on it. Once you do this, go to the bottom of the same section and you will find two buttons: rename and delete. Click on rename in order to change the name of the button.
  6. Once your design is ready, click on "blocks" to start programming your app. The "Palette" menu will now be called "Blocks". These blocks are actually instructions that are used to program your app. The first code you'll need to make is the one that will enable the app to connect to the bluetooth module. The finished code is shown in the second picture.
  7. You can now make the code for each button. This is the main part of the app because, thanks to this, you will be able to use your Android device as your controller. The next pictures show how this code should be done.
  8. The letters chosen to be sent whenever you click a button will control the Arduino. On the next section about the Arduino code this will be explained.
  9. Once you've finished your app, click on build, then App (provide QR code). Scan it with your cellphone to be able to use the app.
  10. When you want to connect to your bluetooth module, select the "Connect" picklist to show every bluetooth device that's available. Be careful to choose the one that corresponds to your car.

Step 4: Step 3: Creating the Arduino Code

Once you have your cellphone app ready now you'll need to program your Arduino Uno.

1. First of all, you'll need to download the libraries that are needed to make the program. These are needed in order to be able to work with the Adafruit motor Shield. After downloading, you should copy them to the folder in which you have all of the Arduino libraries.

2. Once you've installed them, you can start writing your code. It is very important that you include your libraries before you do anything else. You should type:

#include
#include
#include "utility/Adafruit_MS_PWMServoDriver.h"
#include
#include

3. Now, you have to declare your four DC motors for the four wheels. You also need to declare your inputs for the Bluetooth and the servomotor.

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *myMotor1 = AFMS.getMotor(1);
Adafruit_DCMotor *myMotor2 = AFMS.getMotor(2);
Adafruit_DCMotor *myMotor3 = AFMS.getMotor(3);
Adafruit_DCMotor *myMotor4 = AFMS.getMotor(4);
int led=13;
char estado; SoftwareSerial dospositivo (10, 11); //Rx=10, Tx=11
Servo myservo;

4. In the "Setup" section the speed of each motor, initial position, and the PIN at which the servomotor is connected will be assigned.

void setup() {
Serial.begin (9600);
Serial.printIn("Adafruit Motorshield v2- DC Motor test!");
pinMode(led, OUTPUT);
AFMS.begin();
dispositivo.begin(9600);
myMotor1->setSpeed(255);
myMotor2->setSpeed(255);
myMotor3->setSpeed(255);
myMotor4->setSpeed(255);
myservo.attach(9);
myservo.write(0);
}

5. In the Loop section the direction in which each motor spins will be assigned. This will help to define in which direction the car as a whole will move. It will depend on which letter is sent by the controller App. You have to make sure that the letters that you use in your Arduino code match the letters declared on your App.

void loop() {
estado = '0';
if(dispositivo.available()>0) {
estado=dispisitivo.read();
}
switch (estado) {
case 'e': //forward
myMotor1->run(FORWARD);
myMotor2->run(FORWARD);
myMotor3->run(FORWARD);
myMotor4->run(FORWARD);
break;

case 'f': //right
myMotor1->run(FORWARD);
myMotor2->run(FORWARD);
myMotor3->run(BACKWARD);
myMotor4->run(BACKWARD);
break;

case 'g': //reverse
myMotor1->run(BACKWARD);
myMotor2->run(BACKWARD);
myMotor3->run(BACKWARD);
myMotor4->run(BACKWARD);
break;

case 'h': //left
myMotor1->run(BACKWARD);
myMotor2->run(BACKWARD);
myMotor3->run(FORWARD);
myMotor4->run(FORWARD);
break;

case 's': //stop
myMotor1->run(RELEASE);
myMotor2->run(RELEASE);
myMotor3->run(RELEASE);
myMotor4->run(RELEASE);
break;

case 'q': //attack
myservo.write(150);
delay(500);
myservo.write(30);
delay(500);
myservo.write(150);
delay(500);
break;
}

Step 5: Step 4: Connecting Your Motors to Arduino

  1. Put the Adafruit Motor Shield on top of the Arduino UNO. You will have to weld the pins of the Arduino to the Adafruit. This will not only help them both work but will also keep them together. It is recommendable that you find female headers with pins long enough to reach the arduino connections. This will make connecting the bluetooth module to the Adafruit easier.
  2. Once you have both the Arduino and Adafruit together. You can now start connecting your motors to the Adafruit. The Adafruit has inputs for up to four DC motors. You can connect these using some cables. The fifth input with the labels M+ and GND are where you need to connect the power supply of the Adafruit. This other supply will be provided by the same battery that's connected to Arduino, that's why in the "Materials" section it is specified that the external battery should have two slots for two cables.
  3. Connect your servo motor to the input of the Adafruit that's labeled as "Servo 2"
  4. MAKE SURE THAT YOU NEVER HAVE THE JUMPER PLUGGED IN WHILE THE ARDUINO AND ADAFRUIT ARE WORKING. If it is plugged in while feeding the Adafruit, it will get damaged.
  5. Once you have it all connected, test if your bluetooth app is able to make the motors move the way you wish them to.

Step 6: Step 5: Assembling the Car

  1. Before going onto this step, you should first verify that your car works correctly. Check that the bluetooth app is able to connect to the Arduino, that the wheels spin in the direction they are supposed to and that the servomotor spins every time you command it to. If everything's working fine, you can now build the car. Since you have 2 copies of the same chassis, they will be referred as chassis 1 and 2.
  2. Attach the four DC motors, Arduino with Adafruit, servo motor and battery to chassis 1. You may use glue or any other material you wish.
  3. Stick a couple of wooden sticks to the chassis 1. You can cut them according to the desired height of the car. Stick chassis 2 on top of these sticks.
  4. Before fixing the servomotor to chassis 2, you should first attach your weapon for popping balloons to the servo. In this example the weapon consists on a rectangle made out of MDF with a piece of cardboard on the other end. Attach as many push pins as you can to this cardboard piece. You can define its size however you want.
  5. Once you have the weapon ready, paste it to the servomotor. Preferably use glue to prevent it from falling or becoming loose.
  6. You can drill some 4 small holes on chassis 2 to put other wooden sticks there. These sticks will be used to tie the balloons. If the wholes are too big for them to be still you can use a glue gun to keep them still.
  7. After you've finished attaching every component make sure that it is correctly fixed and that it won't fall off easily.

Step 7: Your Car Is Now Ready

Comments

About This Instructable

1,104views

12favorites

License:

More by Zeners1:Remote Control Car With Arduino and Bluetooth
Add instructable to: