Instructables

Beginners guide to building Arduino robots with Bluetooth and Android

Picture of Beginners guide to building Arduino robots with Bluetooth and Android
In this tutorial we are going to go over building a Arduino robot that can be controlled via bluetooth with an Android phone/tablet. This is a beginners guide that is going to briefly go over the process of wiring and programming your robot.  
 
Remove these adsRemove these ads by Signing Up

Step 1: Build list...

Picture of Build list...
The following is the list of components we are going to use:

1.   Pololu Zumo chassis              http://www.zagrosrobotics.com/shop/item.aspx?itemid=884
2.   DRV8833 dual motor driver    http://www.zagrosrobotics.com/shop/item.aspx?itemid=879
3.   Arduino Uno or compatible     http://www.zagrosrobotics.com/shop/item.aspx?itemid=868
4.  Bluetooth modem                    http://www.zagrosrobotics.com/shop/item.aspx?itemid=883
5.  Android phone or tablet

Along with that list of parts for the robot you are going to need these basic things to build and program your robot

1,   Computer with the Arduino IDE    http://arduino.cc/en/Main/Software
2.   Soldering iron
3.   Some solder and wires

Step 2: Assembly...

Picture of Assembly...
After you have assembled your robot chassis and solderd your motor driver and modem, the next step is to wire up your Arduino Uno to the motor drivers and chassis. Here is the wiring diagram


Arduino PIN      GND   --    DRV8833      GND
Arduino PIN         10    --    DRV8833      ain2
Arduino PIN         11    --    DRV8833      ain1
Arduino PIN           5    --    DRV8833     bin1
Arduino PIN           6    --    DRV8833     bin2
Arduino PIN      GND    --    DRV8833    GND
Arduino PIN        VIN    --    DRV8833     VIN

Arduino PIN     (TX)1    --    Silvermate    RX
Arduino PIN     (RX)0   --    Silvermate    TX
Arduino PIN          5V    --    Silvernate VCC
Arduino PIN       GND   --    Silvernate GND
Silvermate           CTS   --    Silvermate  RTS

Step 3: Arduino Sketch...

Picture of Arduino Sketch...
Download the attached sketch and flash it to your Arduino. If you are new to Arduino you can always reference their home page and or the Playground for ideas and insight into everything Arduino.

Robots sketch download link  https://www.box.com/s/25c8f3c14c8b0217759e 

Home page  http://www.arduino.cc/

Playground    http://arduino.cc/playground/
vladometh4 months ago

Hi!, I have a question:

Could I use this instead the DRV8833 dual motor driver?

http://5hertz.com/index.php?main_page=product_info...

fswan7 months ago
hey I'm in the UK and cant get access to all the different components so I have 2 questions.
1. could I use this for my Bluetooth modem - http://www.amazon.co.uk/Bluetooth-Module-Wireless-Serial-Arduino/dp/B00DJQ5Q5Q/ref=sr_1_2?ie=UTF8&qid=1388606312&sr=8-2&keywords=bluetooth+slave

2.is it possible to use the arduino motor sheild instead of the dual motor drive
fswan fswan7 months ago
ignore the second question I found one that should work.... hopefully
hammad780511 months ago
i wana ask that can we communicate b/w android and arduino(any other microcontroller) via usb cable?? bluetooth's data rate is lesser than of usb..
ZRob314 (author)  hammad780511 months ago
Yes you can use USB. Although for this Instructable, which is only sending simple strings, there is plenty of bandwidth to handle this type of simple control. Plus bluetooth gives us the advantage of not being tethered to the robot. I would suggest reading up on the data sheets for the type of Microcontroller you are using to see what speeds are available and how to incorporate them. Try this link for some information on Maximum baudrates with Arduino- http://forum.arduino.cc/index.php?topic=21497.0 -Atom
Is the dual motor driver needed if I use servos to drive the chassis instead?
ZRob314 (author)  dracorabbid1 year ago
No, but you will have to do some modification to the Arduino Sketch in order to get your robot moving. I suggest looking over the Arduino Servo Library - http://arduino.cc/en/reference/servo to get some insight into rewriting the code. -Atom
epierce1 year ago
Will this work with wifi instead of bluetooth?
ZRob314 (author)  epierce1 year ago
The Android application is built around using Bluetooth comm vs WiFi so it would require a major rewrite. It might be interesting to use WiFi vs bluetooth. Which Arduino wifi shield are you looking at using?
Xbee I have seen some apps around, darned if I can find one now!
I had a lot of trouble with the above sketch. Once I got my mind around and the particular requirements of the Ardumoto motor control board, I made a few changes that will allow people to build this project while using the Ardumoto.

Cheers
/* Here is a work in progress based on file found at http://www.instructables.com/id/Beginners-guide-to-building-Arduino-robots-with-Bl/
I the following changes from the original:

1) Power pins are 3 and 11 and digital pins are 12 and 13 to work with the Ardumoto motor control shield. https://www.sparkfun.com/products/9815?
2) MDFLY bt tranceiver defaults to 9600 baud http://www.mdfly.com/index.php?main_page=product_info&cPath=8_47&products_id=769
3) Serial monitor test will not work with Ardumoto in place because MDFLY uses serial pin 0/tx.
4) Case statements had to be completely reworked with matching serial output
5) Added forward and reverse veering case statements with 100/190 power bias.
6) Left and right cases feature20% power counter rotating tracks for on the spot zero radius turns.
7) Max_Control App -- https://www.box.com/s/8b06bcee9ec84ec70a72 this works perfectly but workin in progress to map veering keys to the interface

If you have questions or comments contact me @ celtic.smile.762@gmail.com */

int r_motor_n = 12; //PWM control Right Motor -
int r_motor_p = 3; //PWM control Right Motor +
int l_motor_p =11; //PWM control Left Motor +
int l_motor_n = 13; //PWM control Left Motor -
int incomingByte = 0; // for incoming serial data


void setup()
{
pinMode(r_motor_n, OUTPUT); //Set control pins to be outputs
pinMode(r_motor_p, OUTPUT);
pinMode(l_motor_p, OUTPUT);
pinMode(l_motor_n, OUTPUT);

digitalWrite(r_motor_n, LOW); //set both motors off for start-up
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
digitalWrite(l_motor_n, LOW);


Serial.begin(9600);

Serial.print("Enter keys -- q, f, e, l, b, r, z, c for drive control \n");
Serial.print("w = Forward \n");
Serial.print("s = Backward \n");
Serial.print("d = Right \n");
Serial.print("a = Left \n");
Serial.print("q = frwd_veer left \n");
Serial.print("e = frwd_veer right \n");
Serial.print("z = rev_veer left \n");
Serial.print("c = rev_veer right \n");
Serial.print("x = Stop \n");
Serial.print("Zagros Robotics, Inc.");
}

void loop()
{




if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
}




switch(incomingByte)
{
case 's':
digitalWrite(r_motor_n, LOW);
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
digitalWrite(l_motor_n, LOW);
Serial.println("Stop\n");
incomingByte='*';

break;

case 'r':
digitalWrite(r_motor_n, LOW);
analogWrite(r_motor_p, 50);
digitalWrite(l_motor_n, HIGH);
analogWrite(l_motor_p, 50);
Serial.println("Right\n");
incomingByte='*';
break;

case 'e':
digitalWrite(r_motor_n, HIGH);
analogWrite(r_motor_p, 100);
digitalWrite(l_motor_n, HIGH);
analogWrite(l_motor_p, 190);
Serial.println("veer Left\n");
incomingByte='*';
break;

case 'l':
analogWrite(r_motor_p, 50);
digitalWrite(r_motor_n, HIGH);
analogWrite(l_motor_p, 50);
digitalWrite(l_motor_n, LOW);
Serial.println("Left\n");
incomingByte='*';
break;

case 'q':
digitalWrite(r_motor_n, HIGH);
analogWrite(r_motor_p, 190);
digitalWrite(l_motor_n, HIGH);
analogWrite(l_motor_p, 100);
Serial.println("Veer Right\n");
incomingByte='*';
break;

case 'f':
digitalWrite(r_motor_n, HIGH);
analogWrite(r_motor_p, 190);
analogWrite(l_motor_p, 190);
digitalWrite(l_motor_n, HIGH);
Serial.println("Forward\n");
incomingByte='*';
break;


case 'b':
analogWrite(r_motor_p, 190);
digitalWrite(r_motor_n, LOW);
digitalWrite(l_motor_n, LOW);
analogWrite(l_motor_p, 190);
Serial.println("Back\n");
incomingByte='*';
break;

case 'c':
analogWrite(r_motor_p, 190);
digitalWrite(r_motor_n, LOW);
digitalWrite(l_motor_n, LOW);
analogWrite(l_motor_p, 100);
Serial.println("Veer Back Right\n");
incomingByte='*';
break;

case 'z':
analogWrite(r_motor_p, 100);
digitalWrite(r_motor_n, LOW);
digitalWrite(l_motor_n, LOW);
analogWrite(l_motor_p, 190);
Serial.println("Veer Back Right\n");
incomingByte='*';
break;

case 'v':
Serial.print("MiniBot Version 8/4/2012 ");
Serial.println();
Serial.print("Zagros Robotics, Inc.");
incomingByte='*';
break;

delay(5000);

}
}
ZRob314 (author)  celticsmile1 year ago
This example didn't use the Ardumoto, however it is a great choice.
We also have a basic Ardumoto example on our website:
http://www.zagrosrobotics.com/files/Motor_Control_09192010.zip
Great instructable and thanks for posting. This worked right off for me when I tried, the only thing I had to change was to switch the baud rate for my BT dongle (9600).
Herminator1 year ago
Hey awesome ible,
Ive never used Arduinos before so I have a few questions.

Would an Arduino Nano v3 work in this application?

Can I use this bluetooth module?
http://dx.com/p/jy-mcu-arduino-bluetooth-wireless-serial-port-module-104299
ZRob314 (author)  Herminator1 year ago
If you are new to Arduino I would recommend using the listed products as things can become complicated for the beginner when understanding voltage differences and pinout locations for different Arduino inspired boards as well as editing Arduino sketches for custom scenarios. But I believe that this tutorial is compatible with the Nano double check that the voltage of your board is 5v otherwise it might not power the motors. I would refer to the Arduino website for additional information on your board specs. And for the bluetooth module you listed it should work but hooking it up to your Nano might be differnt than what my diagram suggests. Check data sheets or website information on setting up your bluetooth module to verify. -Atom