loading
Picture of Hercules: The Motion Controlled Android Robot
Hercules.jpg
100_0332111.jpg
When I was in the 8th grade, I was intrigued while playing the motion games on Nokia 5800. I was thrilled, how I could control the racing car by only tilting the phone. I used to dream of making this same car in the real world. 

Now, in 11th  grade ( Age 17) having got an Arduino Uno and learnt how to program it, I was able to build my "Hercules" robot. 

Hercules is the name given to my motion controlled robot because of its immense torque and speed. The robot is controlled by an android phone through bluetooth. The advantage of using an android phone to control the robot, is that I can use any android phone to control it and am not confined to using only one controller for the robot. The use of an android phone as a controller, significantly reduces the cost of the project, since money is not spent in building a controller for the robot.    

The Hercules was built for the 2012 Indian Institute of Technology, Mumbai's IIT Techfest ( Asia's largest tech festival ). The objective was to build a motion controlled robot that could race around an obstacle track.
 
Remove these adsRemove these ads by Signing Up

Step 1: Step 1: Parts Needed:

For making this robot you need the following parts :

         Supplies :

1.     Arduino Uno. 
2.     
Bluetooth Transceiver Chip ( Serial Bluetooth Modem).
3.     L298 Dual H-Bridge IC.
4.     4pcs of Geared Motor (Specifications depend on application of the robot).
5.     4pcs of wheels.
6.     12v 1Ah SLA Battery.
7.     Base plate for the robot components.
8.     3cms x 7cms PCB.
9.     4pcs of Project Enclosure / boxes .
10.   SPST Switch.
11.   Male Header Pins (Straight).
12.   Wire.
13.   Small Screws and nuts.
14.   Resistors ( 1pc 10K ohms and 1pc 20k ohms).
15.   Android phone.


            Tools :

1.   Soldering iron.
2.   Solder.
3.   Soldering wax.
4.   Drill.
     


Step 2: Step 2: Chassis and wheels

Picture of Step 2: Chassis and wheels
100_0351.JPG
100_0352.JPG
The big screws on the motor make it easy to mount on chassis. The wheels slide on to the motor shaft and get screwed in place.
Connect the Left Side Motors in parallel. Connect the Right Side Motors in parallel. 
After fitting the four motors and wheels, you should have something that looks like the first picture. 

Step 3: Step 3: The Circuit: Arduino Box

Picture of Step 3: The Circuit: Arduino Box
100_0447.JPG
100_0443.JPG
100_0444.JPG
100_0343.JPG
The principle of divide and rule can be applied in every aspect of our life. This simple principle is also applied to this circuit. The circuit is divided into different boxes. This modular design makes it easy to maintain and troubleshoot the circuit. If some component burns off during the competition or when it is being run, then the corresponding module can be replaced quickly.

Arduino Box:

1.
  Cut the PCB using a hacksaw into 4 parts as follows: a) 2 nos. of PCB each having eight holes in length and three holes in breadth and b) 2 nos. of PCB each having six holes in length and three holes in breadth; which after assembling should look like the first picture. 

2.   Place the male header pins along the length of the cut PCB and solder them in place. It should look like the second picture.

3.   Solder  wires (approx 4 inches in length) to each of the header pins. Refer to picture 4. Now you are done with the header pins array for the arduino. By using this technique, the header pins do not come off easily from the Arduino as the force is distributed equally between the pins.

4.   To prepare the project enclosure(box) for the Arduino Uno; first, temporarily place the Arduino Uno in the box. Place it in such a way that the USB port end touches the breadth of the box at one end and you can mark the part which you must cut/drill (as the USB port should stick out of breadth of the enclosure). This will help us program the Arduino board even after it is installed in the robot. After cutting/drilling the enclosure, again temporarily place the Arduino Uno in the enclosure, and apply some force making sure that the USB port sticks out of the enclosure. With the Arduino Uno in this position, you will now have to mark and drill sixteen small holes on the upper end of the enclosure's length so that the wires coming out of the PCB circuit will pass through this enclosure (ready to be attached to some other circuit); and diagonally opposite, mark and drill twelve small holes on the lower end of the enclosure's length so that the wires coming out of this PCB circuit will pass through the enclosure (ready to be attached to some other circuit). Note how these well planned holes help the header pin wires to come out neatly from the project enclosure box. Drill four small holes on the base of the box as per the four holes already there on the Arduino Uno so that with the help of small screws and nuts, you can permanently hold the Arduino in place.

5.   Finally place the Arduino in the box and fasten it with the small screws and nut to the base of the project enclosure. Fit the header arrays on the arduino pins and drive the wires of the header pins array through the holes made in the enclosure box.

6. Now you are done with the Arduino Box. The Arduino box should look something like the first picture. 
 


 


Step 4: Step 4: The Circuit: Bluetooth Transceiver Box

Picture of Step 4: The Circuit: Bluetooth Transceiver Box
RF_Transceiver_Module_rs232_Bluetooth_module.jpg
100_0428.JPG
The most tricky part of this instructable is soldering the wires to the tranceiver. A third hand is always useful for such applications.

1. Solder a wire 4 inches in length to pin 1. This is the Tx pin.

2. Solder a wire 4 inches in length to pin 2. This is the Rx pin.

3. Solder a wire 4 inches in length to pin 12. This is the +3.3v pin.

4. Solder a wire 4 inches in length to pin 13. This is the Ground (GND) pin.

Place this bluetooth trasceiver in a small enclosure or box having holes for the wires to exit. Make sure you glue the wires to the box. This acts as a stress relief mechanism preventing the soldered wires from coming off under any pressure. The bluetooth module I got is from ebay. It is quite cheap and reliable, so much so that I use the same bluetooth module in my middleweight combat robot.    

Step 5: Step 5: The Circuit: The Resistor Box

Picture of Step 5: The Circuit: The Resistor Box
100_0419.JPG
Resistor Box.jpg
The arduino sends serial output of 5v through the Tx pin, whereas the bluetooth transceiver module uses 3.3v logic. So a voltage divider circuit ( level shifter ) is required to convert this 5v output to 3.3v. Follow the schematic diagram and solder the resistors on the remaining piece of PCB. If your arduino enclosure is big enough, then you can have this circuit within the arduino box, else you will have to use another small box for this circuit.     

Step 6: Step 6: The Circuit: Motor Controller

Picture of Step 6: The Circuit: Motor Controller
100_0436.JPG
100_0121.JPG
100_0431.JPG
The motor controller used for the project is an L298 IC. It is a dual H-Bridge IC which is used to control the four motors of the robot. I made a custom etched PCB for the L298 (pic. 3) which makes soldering the wires easy to the L298 pins. If the resources for making a custom etched PCB are not available, then solder a wire to each pin of the L298 IC. After soldering the wires, place the IC in a small enclosure having holes drilled in it for the wires to leave the box. Your Motor Controller box should look something like the first picture. 

Step 7: Step 7: The Circuit: Final Connections

Picture of Step 7: The Circuit: Final Connections
L298.jpg
Interconnect the Arduino Box, the Bluetooth module, the resistor box according to the first picture. 

The pin connections of the L298 Motor Controller and the Arduino are as follows :- ( Refer to L298 pinout - picture 2)

1----Ground

2----Pin 1 of Left Side Motors  

3----Pin 2 for Left Side Motors

4---- +12v battery

5---- Arduino Pin 2 

6---- Arduino Pin 3

7---- Arduino Pin 4

8---- Ground

9---- +5v from Arduino

10---- Arduino Pin 5

11---- Arduino Pin 6

12---- Arduino Pin 7 

13---- Pin 1 of Right Side Motors

14---- Pin 2 of Right Side Motors

15---- Ground


Connect the +12v terminal of the battery through a switch to the Vin pin of the Arduino and to pin 4 of the L298 IC.
Connect the -ve terminal of the battery to the Ground (GND) pin of the Arduino.

Step 8: Step 8: Programming the Arduino

Picture of Step 8: Programming the Arduino
Before you can program the Arduino Uno, you have to install the Amarino library for the Arduino. These are the steps to install the library :-

1.   Download the  Amarino library for the Arduino (link).

2.   Extract the zip file to the folder: arduino_install_dir/libraries/extract_meetandroid.zip_here

3.  
Now you would see the library under   " Sketch --> Import Library "  in the Arduino IDE.

4.   You can proceed with the Arduino Uno programming.



The following is the source code for the Arduino. Copy the code below and load it on the Arduino :-


#include <MeetAndroid.h>

const int EnablePin1 = 3;
const int EnablePin2 = 6;
const int Motor_1_A = 2;
const int Motor_1_B = 4;
const int Motor_2_A = 5;
const int Motor_2_B = 7;
float data[3] = {0};
int intdata[3] = {0};
int i = 1;


MeetAndroid meetAndroid(error);

void error(uint8_t flag, uint8_t values)
{
  Serial.print("ERROR: ");
  Serial.print(flag);
}


  void setup() {
  Serial.begin(9600);
  Serial.println("\t\t\t.----------------------.");
  Serial.println("\t\t\t|    Starting Up..     |");
  Serial.println("\t\t\t'----------------------'");
  pinMode(EnablePin1, OUTPUT);
  pinMode(EnablePin2, OUTPUT);
  pinMode(Motor_1_A, OUTPUT);
  pinMode(Motor_1_B, OUTPUT);
  pinMode(Motor_2_A, OUTPUT);
  pinMode(Motor_2_B, OUTPUT);
  delay(1000); 
 
 
  meetAndroid.registerFunction(floatValues, 'A'); 


}

void loop()
{
  meetAndroid.receive(); 
}
void floatValues(byte flag, byte numOfValues)
{
 
  meetAndroid.getFloatValues(data);
 
  for (int i=0; i<3;i++)
  {
    meetAndroid.send(data[i]);
  }
 
      if (-10<=data[0]<=10) //        This is for Forward/Reverse
      {

        intdata[0] = int(data[0]);
        intdata[0] = intdata[0] * 24;
            if (data[0] <= -2)
            {
              intdata[0] = abs(intdata[0]);
              digitalWrite(Motor_1_A, HIGH);
              digitalWrite(Motor_2_A, HIGH);
              digitalWrite(Motor_1_B, LOW);
              digitalWrite(Motor_2_B, LOW);
              analogWrite(EnablePin1, intdata[0]);
              analogWrite(EnablePin2, intdata[0]);
            }
            else if (data[0] >= 2)
            {
              digitalWrite(Motor_1_A, LOW);
              digitalWrite(Motor_2_A, LOW);
              digitalWrite(Motor_1_B, HIGH);
              digitalWrite(Motor_2_B, HIGH);
              analogWrite(EnablePin1, intdata[0]);
              analogWrite(EnablePin2, intdata[0]);
            }  
            else if (-1<=data[0]<=1)
            {
              digitalWrite(Motor_1_A, LOW);
              digitalWrite(Motor_2_A, LOW);
              digitalWrite(Motor_1_B, LOW);
              digitalWrite(Motor_2_B, LOW);
              digitalWrite(EnablePin1, LOW);
              digitalWrite(EnablePin2, LOW);
            } 
      }


    if (-10<=data[1]<=10)  //        This is for Turn Left/Turn Right
    {
                if (data[1] <= -2)
                {
                  digitalWrite(Motor_1_A, HIGH);
                  digitalWrite(Motor_2_B, HIGH);
                  digitalWrite(Motor_1_B, LOW);
                  digitalWrite(Motor_2_A, LOW);
                  analogWrite(EnablePin1, intdata[0]);
              analogWrite(EnablePin2, intdata[0]);
                }
                else if (data[1] >= 2)
                {
                  digitalWrite(Motor_1_A, LOW);
                  digitalWrite(Motor_2_B, LOW);
                  digitalWrite(Motor_1_B, HIGH);
                  digitalWrite(Motor_2_A, HIGH);
                  analogWrite(EnablePin1, intdata[0]);
                  analogWrite(EnablePin2, intdata[0]);
                }
                else if (-1<=data[1]<=1)
                {
                  digitalWrite(Motor_1_A, LOW);
                  digitalWrite(Motor_2_A, LOW);
                  digitalWrite(Motor_1_B, LOW);
                  digitalWrite(Motor_2_B, LOW);
                  digitalWrite(EnablePin1, LOW);
                  digitalWrite(EnablePin2, LOW);
                }    
    }
   
}

Step 9: Step 9: Software for Android

Picture of Step 9: Software for Android
What is Amarino ?


Amarino is a toolkit designed to work with smartphones based on the Android open source operating system. The good thing is, you don't need any programming knowledge in Android at all to get started with. You can start right away just by installing the provided Android application on your phone. It comes already with many preinstalled events you can select to send it over to your Arduino.

Downloading the Amarino App :

Here is a video on how to install the Amarino App and plugin.




The following are the steps for downloading the Amarino Application:-
  1.  Download the Amarino Application (link) and the Amarino plugin (link) on your computer.
  2.  Copy the Amarino App and Amarino plugin to the Android phone's SD card.
  3.  Install the Amarino App and the Amarino plugin on the Android phone.
  4. Turn On the Bluetooth robot.
  5. On the Android phone go to "Settings-->Wireless and Network-->Bluetooth Settings". Turn on the bluetooth and search for your bluetooth module. Once the bluetooth module is discovered, pair with it but do not connect to it.
  6. Open the Amarino App on the Android phone. Click the "Add BT Device" button. Select the bluetooth module from the list of devices.
  7. Your bluetooth module now appears on the Amarino homescreen. 
  8. Select the red file button next to the bluetooth module's name. 
  9. Select the "Add Events" button and select the "Accelerometer Sensor" option.

You are now done with installing the Software part on the Android Phone

Step 10: Step 10: Driving the Hercules

Picture of Step 10: Driving the Hercules
You are done with building the Hercules robot, so now its time to drive the beast.


These are the steps to drive the Hercules:
  1. Turn on the Hercules robot.
  2. Open the Amarino Application on the Android phone.
  3. Click the "Connect" button to connect the Android phone to the robot.
  4. Tilt the phone to move your Hercules robot.
Notice that the robot's speed is proportional to how much you tilt your Android phone. This is the tilt proportional drive of the Hercules robot.

It could so happen that the robot goes in an undesired direction. Under such cases, invert the wires going to the motor which side goes in the wrong direction.

And there you go, you have built your very own Motion Controlled Robot..

If you have any difficulties building your Robot, do feel free to ask.

GREAT!!!!! NOW GO AHEAD AND CONSTRUCT ONE YOURSELF!!!!! : )

1-40 of 102Next »
Akshay Jha10 months ago

hiiiii vineet i just want to know from where you learn arduino and android both because i have made many projects of arduino and microcontroller but the shamefu thing is that i had never written my project code itself so i want your help to learn language for arduino plz guide me and reply soon you can also mail me at akshay20jha@gmail.com

Hi, compliments for the very nice tutorial|

I'm a beginner and I would appreciate if you can give me a help:

I do have Arduino uno and a motor shield adafruit as you can see on the image,

Can you please suggest how can I modify your sketch just to use it and explain in a way so that I can understand?

I hope to no disturb you with this!

Thanks a lot

Regards

Arnaldo

PS- My email just in case you want to email me.

arnaldo.armida@gmail.com

adafruit-motorshield.jpg
abencomo1 year ago

Nice work! We built a similar project. However, we installed an Android device onto a RC car and used an IOIO board instead to control it autonomously. Here is the preliminary result:

http://youtu.be/vkvkfcqEUkk

i am using arduino duemilanove instead of uno and the recieved output is random

please HELPPP

gm4afsal1 year ago

Guys...Just download and use Arduino 0022. Meet android problems will be solved then.
:)

YARiK_9971 year ago
Hi. i"ve got this error in arduino

In file included from sketch_sep26a.ino:1:
C:\Users\ADiTHYA_PC\Documents\Arduino\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
I do not know why some people are getting this error these days. I had written the program in Arduino ADK version 0022 hence try installing the version 0022 and see if that helps.
nskcoolguy1 year ago
can i use arm 7 instead of using arduino....
You could use the arm 7 instead of the Arduino, but I cannot help you out with that as I have no experience working with ARM processors.
vkadnor1 year ago
hey can i use arduino leonardo
bhar923 years ago
Hey Jayvis! Your robot inspired our first robot, the Mastadon! http://blimp12.blogspot.in/2012/07/mastodon-10-and-diy-dinner.html
Thank you so much!
Jayvis Vineet Gonsalves (author)  bhar923 years ago
I'm glad hearing about how you replicated the robot. Enjoy with it now. You can customize it in a number of ways to suit different purposes. All the best !! Btw where do you live in India ?
I live in Bangalore, and you?
Jayvis Vineet Gonsalves (author)  bhar923 years ago
I live in Mumbai
JAYVIS i too lived in mumbai...

i hv a prblm wit prgm will u plz upload it again
hey jayvis i liked ur robot and i m too from mumbai


love to so many Indians on instructables !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Every sixth person on this Earth is an Indian, so you could somewhat expect the same proportion here to. Hehe
can u tell me frm where did u get the blue tooth module and instead of L298 can i use l293D??
The L298 is quite common and can be purchased from Lamington Road. As for the Bluetooth Module, I ordered it from Ebay.com (Not Ebay.in)
can i get a bluetooth module frm lamington rod?
and while a upload the sketch i get this error
In file included from sketch_jan19a.cpp:1:
C:\Documents and Settings\PRANAV JAIN\My Documents\arduino-1.0.1\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
C:\Documents and Settings\PRANAV JAIN\My Documents\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t what should i do?
I do not know about the error as I am able to compile the program. Have you downloaded the Amarino plugin?

And about the bluetooth module, try your luck at Lamington but expect it to be overpriced if available.
which module did u buy frm ebay i m geting AUBTM20 with RS232 frm lamington road will it work???

What did u when u compile the sketch i.installed the amaranio libaray on the computer then wat should I do
does it need any plugin on computer????
adi-sreyaj1 year ago

i"ve got this error in arduino


In file included from sketch_sep26a.ino:1:
C:\Users\ADiTHYA_PC\Documents\Arduino\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
janandh1 year ago
hai jayvis will u pls upload coding for controlling motors through blue control..?

wat is the headerfile for this app?any other new library or the same????
i have a problem..
my mobile detects the bluetooth module but i can't access the robot..
i think there must be problem in app..
pls help i have been doing this for 5 months kindly help me plssss
Check out Step 9. It has all the details on how to pair and connect your Android phone with the bluetooth module.
priyadarshu2 years ago
i built the robot as u said but it s not working. bluetooth s getting paired with my mobile but the robot s not moving so pls help me i dont know what to do.pls reply me as early as possible
pbzhedugova2 years ago
Thank you for a fast reply.
Ok, got it about the disconnected blth module. About the second problem: i guess something might be wrong with the blth module itself. I tried to detach it from the system and power just with the 3v battery.
The phone still doesn't see it. Im scanning for bluetooth devices in settings.
P1110129.JPGP1110130.JPG
pbzhedugova2 years ago
Hi Jayvis! I made this robot according to your instructions but I now face some problems.
1)The code doesn't want to upload. It uploads only if I detach all the wires from arduino.
2)My android phone doesn't see the robot by bluetooth

What can I do here?

When I turn on the switch all the lights turn on. On Arduino it's "on" and "L". Bluetooth light is blinking.
Hi,
I have written somewhere in this instructable that the code must be uploaded only when the bluetooth module is disconnected from the Arduino or else the bluetooth module could get damaged.
Regarding the connection issue, you must first pair with the robot through bluetooth settings menu in the android phone. Then you must connect the robot with the phone using the Amarino Software. Hope this helps!
janandh2 years ago
can i get any android apps for both motion controll and video receiving if so plz reply
janandh2 years ago
what are all the applications of it in real time problem if you have any idea plz tell me
janandh2 years ago
i have an error while compiling your program.'meetandroid does not a name type'this error which i had faced.eventhough i ve imported library from amarino im facing this error.what can i do?plz reply me soon..
maniza22042 years ago
can i use 12v DC motor which has lower than 500 rpm ? plz help
i cant find any at nearest shop in my town.
maniza22042 years ago
hi jayvis, i was so thrilled at first when trying to built the same robot like u did/
but im having problem with the programme, help me plezz
it says :
In file included from sketch_feb22a.cpp:1:
C:\Users\LaPtOp PuNoH\Desktop\mat\arduino-1.0\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
C:\Users\LaPtOp PuNoH\Desktop\mat\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
hey i m trying verify the sketch this error cums

In file included from sketch_jan19a.cpp:1:
C:\Documents and Settings\PRANAV JAIN\My Documents\arduino-1.0.1\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
C:\Documents and Settings\PRANAV JAIN\My Documents\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t
Hi...
I am experiencing a problem regarding your code...
It says MeetAndroid is not a type???
What to do??
This problem was resolved but i m experiencing another problem...
I remade your project but failed to get serial data from the bluetooth module...
Tell me what to do???
But i m able to send and receive serial data through arduino serial monitor...
1-40 of 102Next »