Beginners guide to building Arduino robots with Bluetooth and Android

 by ZRob314
Robot.jpg
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...

Parts.jpg
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

dracorabbid says: May 25, 2013. 2:25 AM
Is the dual motor driver needed if I use servos to drive the chassis instead?
ZRob314 (author) in reply to dracorabbidMay 26, 2013. 1:25 PM
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
epierce says: Apr 3, 2013. 2:28 PM
Will this work with wifi instead of bluetooth?
ZRob314 (author) in reply to epierceApr 3, 2013. 4:10 PM
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?
epierce in reply to ZRob314Apr 5, 2013. 8:45 PM
Xbee I have seen some apps around, darned if I can find one now!
celticsmile says: Feb 6, 2013. 6:11 PM
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) in reply to celticsmileFeb 9, 2013. 10:00 PM
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
syberjunkie says: Dec 13, 2012. 4:10 AM
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).
Herminator says: Oct 2, 2012. 9:09 AM
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) in reply to HerminatorOct 26, 2012. 12:19 PM
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
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!