Introduction: 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.  

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/

Step 4: Testing Our Robot...

Picture of Testing Our Robot...

Now that we have flashed our Arduino Uno with the attached sketch, we can use USB to communicate with the Uno to send motor commands based on string commands. In order to do this we use the Arduino IDE serial monitor. Make sure that your baud rate set on your serial monitor window is the same as the baud rate in our sketch (115200).   Now we can send commands like 

f   ( Forward ) ,  b  ( Back ) ,  l  ( Left ) ,  r  ( Right )



Step 5: Android App...

Picture of Android App...

Here is a basic Android app that sends string commands via bluetooth to our Arduino Uno. Of coarse you can always write you own .apk to Incorporate a more advanced interface using your phones accelerometer, or touchscreen using sliders for motor speed and direction. Transfer the .apk to the sd card on your phone or tablet and use an app like ES file explorer to gain access into the SD card and install the .apk.


ES FIle Tutorial -- http://www.youtube.com/watch?v=myOW8YrcSzg



Max_Control App --     https://www.box.com/s/8b06bcee9ec84ec70a72



Step 6: Conclusion...

Picture of Conclusion...



This hopefully has helped you get a basic understanding of how to incorporate Arduino with Bluetooth and Android. I have also included a printable robot that you can print on card stock at home or at print shops like Kinkos. Take notice of the page size as it is 10' x 16', if this is too big for your printer use a photo editor to break up the images to a printable format. There are 2 files one blank cutout that you can edit and the other that is pictured in this tutorial. Enjoy your new wireless robot and now you can start planning your next modification to your robot with sensors,servo arms, cameras or higher level programming control with a PC over Bluetooth.

Robot Images  https://www.box.com/s/012d79de3373d3133706

Comments

ashoksoundar (author)2014-09-11

can i use Hc-05 bluetooth modem instead of your bluetooth

vladometh (author)2014-04-22

Hi!, I have a question:

Could I use this instead the DRV8833 dual motor driver?

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

fswan (author)2014-01-01

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 (author)fswan2014-01-01

ignore the second question I found one that should work.... hopefully

hammad7805 (author)2013-09-06

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)hammad78052013-09-24

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

dracorabbid (author)2013-05-25

Is the dual motor driver needed if I use servos to drive the chassis instead?

ZRob314 (author)dracorabbid2013-05-26

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 (author)2013-04-03

Will this work with wifi instead of bluetooth?

ZRob314 (author)epierce2013-04-03

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 (author)ZRob3142013-04-05

Xbee I have seen some apps around, darned if I can find one now!

celticsmile (author)2013-02-06

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 https://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)celticsmile2013-02-09

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 (author)2012-12-13

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 (author)2012-10-02

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)Herminator2012-10-26

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

About This Instructable

102,311views

136favorites

License:

More by ZRob314:Turn on an LED With Watson ConversationSt. Patrick's Day "Pinch Detector" With Circuit PlaygroundPiano Pi - Play a Duet With Your Pi!
Add instructable to: