Introduction: My Eighth Project: Robot Arm With Smart Tank Chassis and Bluetooth

The robot arm is a very interesting stuff. It can move and hold something, but it is confined in a specific place. How about if we put it on a robot car and let the car bring the robot arm to do certain jobs? This is an idea of this project.

Step 1: Parts

Robot Arm Set, or here

Smart Tank Chassis, or here

Arduino MEGA 2560 R3

Bluetooth Module

Buck Regulator with Indicator

7.4V Li-Po Battery

Charger

JST female connector

Small Breadboard

9V Battery Box

Switch

Step 2: Assembly

In this project I need the higher part of the robot arm set only. Take this part off the set and fix it on the smart tank chassis. To make the claw picks thing easily, I have also adjusted the angle of the claw servo and make the claw in horizontal direction when the servo is 0 degree. I've realised that the voltage of Li-Po battery is too strong for the robot arm and the smart tank, so I also bought a buck regulator to reduce the voltage. This buck regulator is so convenient because we can read the voltage of input and output through the indicator. We can use a multimeter to calibrate the indicator at the first time. After that the voltage can easily be adjusted with a screw driver. Let's set the voltage to 5.8V. I fix Arduino MEGA 2560, small breadboard, the buck regulator and 9V battery box on the chassis first and then do wiring.

Step 3: Wiring

The Li-Po battery is connected to the input of the buck regulator and VCC of the output is wiring with a switch and then to breadboard. GND of the output is connected directly to the breadboard. GND and VCC of all servos and two sides of the chassis are linked to GND and VCC of the output with breadboard. To share the same ground, pin GND on Arduino is also connected to GND on the breadboard.

The wiring of the chassis is the same as in the third project. I just copy it as follow:

IB on the right side > pin 8

IA on the left side > pin 9

IA on the right side > pin 10

IB on the left side > pin 11

Let the servo at the bottom be servo1, the middle servo2 and the claw servo3 and they are linked to Arduino as follow:

Servo 1 > pin 5

Servo 2 > pin 6

Servo 3 > pin 7

Step 4: 1st Test

To ensure all the wiring are correct I do a test with the codes below:

For smart tank chassis:

int motorPin = 8; //right side to IB - forward

int motorPin2 = 9; //left side to IA - forward

int motorPin3 = 10; //right side to IA - backward

int motorPin4 = 11; //left side to IB - backward

void setup() {

Serial.begin (9600);

pinMode(motorPin, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

pinMode(motorPin4, OUTPUT);

}

void forward(){

digitalWrite(motorPin, HIGH);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

}

void backward() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, HIGH);

}

void turnLeft() {

digitalWrite(motorPin, HIGH);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, HIGH);

}

void turnRight() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, LOW);

}

void loop () {

forward();

delay(10000);

backward();

delay(10000);

turnLeft();

delay(10000);

turnRight();

delay(10000);

}

For robot arm:

#include <Servo.h>

Servo servo1;

Servo servo2;

Servo servo3;

void setup()

{

servo1.attach(5);

servo2.attach(6);

servo3.attach(7);

}

void loop()

{

servo1.write(40); // move down

servo2.write(0); //turn anticlockwise

servo3.write(40); //claw open

delay(5000);

servo1.write(180); // move up

servo2.write(180); //turn clockwise

servo3.write(110); //claw close

delay(5000);

}

The range of 3 servos are adjusted to avoid any interrupt.

Step 5: 2nd Test

Great! It moves perfectly! So I add the Bluetooth module to Arduino:

VCC > 5V

GND > GND

TXD > pin 3

RXD > pin 2

Upload the code in the 4th project:

#include <SoftwareSerial.h>

SoftwareSerial BT(3, 2); //set TX and RX on bluetooth to pin 3 and 2 respectively

char command;

int motorPin = 8; //right side to IB - forward

int motorPin2 = 9; //left side to IA - forward

int motorPin3 = 10; //right side to IA - backward

int motorPin4 = 11; //left side to IB - backward

void setup() {

BT.begin (9600);

pinMode(motorPin, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

pinMode(motorPin4, OUTPUT);

}

void stop() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

}

void forward(){

digitalWrite(motorPin, HIGH);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

}

void backward() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, HIGH);

}

void turnLeft() {

digitalWrite(motorPin, HIGH);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, HIGH);

}

void turnRight() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, LOW);

}

void loop() {

if (BT.available() > 0) {

command = BT.read();

switch (command) {

case 'w' :

forward();

break;

case 'x' :

backward();

break;

case 'a' :

turnLeft();

break;

case 'd' :

turnRight();

break;

case 's' :

stop();

break;

}

}

}

And use the Android app in the 4th project to test it......

No response.

I've test the robot arm and smart tank separately and both are fine, and I am pretty sure that the Bluetooth module works properly. The problem should be on the wiring. I did swap the RX and TX pin but it didn't work... So discouraging... : (

So I try begging an answer from google and get this information by chance:

http://www.arduino.cc/en/Reference/SoftwareSerialExample

Note:

Not all pins on the Mega and Mega 2560 support change interrupts,

so only the following can be used for RX:

10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

The Bluetooth module failed to communicate with Arduino just because I've used the wrong pin! So I shift TX and RX to 52 and 53 respectively and try again. It works!

Step 6: App

As the Android app before supports the movement of the tank only, I've modified the app and added several buttons to it in MIT App Inventor. For the framework of the app please refer to the photo. The concept is very simple actually: Press a button and send a letter to Arduino via Bluetooth. When Arduino gets a letter, it will do the job I've assigned to this letter. Besides of five buttons before, six more buttons are added to the app: Open, Close, ↶, ↷, ↑ and ↓. If you remember, you will know that I tested and adjusted the range of the three servos in the 1st test. The buttons "↑" and "↓" correspond to up and down movement of Servo 1. "↶" and "↷" to anticlockwise and clockwise movement of Servo 2. "Open" and "Close" to open claw and close claw of Servo 3.

Step 7: Code

Then I combine the code in the 2nd test with servos and enable the servos move in designated ranges.

#include <SoftwareSerial.h>

#include <Servo.h>

SoftwareSerial BT(52, 53); //set TX and RX on bluetooth to pin 52 and 53 respectively

Servo servo1;

Servo servo2;

Servo servo3;

char command;

int motorPin = 8; //right side to IB - forward

int motorPin2 = 9; //left side to IA - forward

int motorPin3 = 10; //right side to IA - backward

int motorPin4 = 11; //left side to IB - backward

int pos1 = 90;

int pos2 = 90;

int pos3 = 90;

void setup() {

BT.begin (9600);

Serial.begin (9600);

pinMode(motorPin, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

pinMode(motorPin4, OUTPUT);

servo1.attach(5);

servo1.write(pos1);

servo2.attach(6);

servo2.write(pos2);

servo3.attach(7);

servo3.write(pos3);

}

void stop() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

}

void forward(){

digitalWrite(motorPin, HIGH);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

}

void backward() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, HIGH);

}

void turnLeft() {

digitalWrite(motorPin, HIGH);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, HIGH);

}

void turnRight() {

digitalWrite(motorPin, LOW);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, LOW);

}

void open() {

for(pos3 = 110; pos3 > 40; pos3 -= 1)

{servo3.write(pos3);

}

}

void close() {

for(pos3 = 40; pos3 < 110; pos3 += 1)

{servo3.write(pos3);

}

}

void antiClockwise() {

for(pos2 = 90; pos2 > 0; pos2 -= 1)

{servo2.write(pos2);

}

}

void clockwise() {

for(pos2 = 0; pos2 < 90; pos2 += 1)

{servo2.write(pos2);

}

}

void up () {

for(pos1 = 50; pos1 < 180; pos1 +=1)

{servo1.write(pos1);

}

}

void down() {

for(pos1 = 180; pos1 > 50; pos1 -= 1)

{servo1.write(pos1);

}

}

void loop() {

if (BT.available() > 0) {

command = BT.read();

switch (command) {

case 'w':

forward();

break;

case 'x':

backward();

break;

case 'a':

turnLeft();

break;

case 'd':

turnRight();

break;

case 's':

stop();

break;

case 'y':

open();

break;

case 'u':

close();

break;

case 'h':

antiClockwise();

break;

case 'j':

clockwise();

break;

case 'n':

up();

break;

case 'm':

down();

break;

}

}

}

Step 8: Result

Do the pairing with my Android phone and open the app. Cool! I got stuck in the problem for a few day and now it works! In this project I've learnt more about troubleshooting: Some problems may not caused by either wiring or coding, but different properties among Arduino boards. This board supports the code doesn't entails that other board can support it. I should pay more attention to it if using different boards. This is the end of this project. Hope I can find other interesting project to start. See you!

Comments

author
ArduinoPower (author)2015-04-21

Can i make this with an Arduino Duemilanove?

author
ibenkos (author)2014-10-28

If I use an xBee can I control it on my computer? I have ordered the robot arm on ebay and im going to make this! :) you are using 3 dof, im going to try whit an 4 dof robot arm :)

author
Rookie P (author)ibenkos2014-10-29

It's cool and I think it works! One xbee connects to Arduino and another xbee to the computer via USB. Honestly I didn't do any project with xbee before so I can't tell much to you, but I've just found another Inscrutable and here is the link: https://www.instructables.com/id/Xbee-quick-setup-guide-Arduino/ Hope this can help. I am looking forward to your great project in Instructable . : )

author
ibenkos (author)Rookie P2014-10-29

Thank you so much! It really helpt! And i have one more question, I dont have the same tank chassis as you have i have one fron an old toy tank whit two motors and the only wires are + and - and on yours u have connected one more, what do I have to do diffrently?

author
Rookie P (author)ibenkos2014-10-30

I think you need a H-bridge electronic circuit which enables Arduino controlling the directions of motor spinning. You can buy L298N chips and create your own circuit, but the easiest way to do so is to buy a motor shield. Just plug this shield to Arduino board and connect it with + and - wire of the motor and that's it.

author
ibenkos (author)Rookie P2014-10-30

Yea I was thinking about buying the arduino motor shield but can I connect the xBee to the shield? Thanks

author
Rookie P (author)ibenkos2014-10-30

I've just read something that is exactly the same case. You may get an idea with this link:

http://www.jayconsystems.com/tutorial/xbee_Shield/

author
ibenkos (author)Rookie P2015-03-25

Sorry if I ask to much :P but is it possible to get the controller you use on my iPhone or is it only on android?

author
dani.azroy (author)2014-12-12

hi, can u help, why does my pin output change when im uploading the code with bluetooth... im using arduino uno and bluetooth shiled..

author
Rookie P (author)dani.azroy2014-12-12

you may test the tank and robot arm without Bluetooth first: do they work when test individually?

author
dani.azroy (author)Rookie P2014-12-12

yeahh it works perfectly, but when i try coding with the bluetooth,, output change automatically

author
Rookie P (author)dani.azroy2014-12-13

i guess that there may be something wrong with the code, are you using exactly the same code as me? or modified by yourself? can you tell me which button has problem when you use the bluetooth?

author
dani.azroy (author)Rookie P2014-12-13

yeahh i upload exactly the same code that u provide.. which is pin 8,9,10,11, but the output change to 0,1 which mean left and right motor shared the same pin... i have used this bluetooth shield and bluetooth module

https://docs.google.com/document/d/1dPsvr6Wi3XAZn8...

http://cytron.com.my/p-bluebee

author
Rookie P (author)dani.azroy2014-12-13

I've just tested the code in Instructables with the same tank, robot arm and bluetooth module in the project, and changed the output to 0,1. It works. Did you checked the jumpers for TX and RX on your shield? They should match the pins of SoftwareSerial BT in the code.

author
dani.azroy (author)Rookie P2014-12-13

still not work, my jumpers tx and rx is 3 and 2 according to the code.. and my pin is 8,9,10,11 and it still change automatically. and i still no idea why it can work only when i connected to 0 and 1 only as my pin..

author
ibenkos (author)2014-10-12

Does it work with Arduino uno r3?

author
Rookie P (author)ibenkos2014-10-12

Yes, they are interchangeable.

author
Rookie P (author)Rookie P2014-10-12

but need to change to pin 2 and 3 for Bluetooth module and amend the code for the corresponding pin.

author
MsSweetSatisfaction (author)2014-08-17

Very cool project! Thanks for sharing!

About This Instructable

3,922views

39favorites

License:

More by Rookie P:My Ninth Project: Robot Arm with Joystick ShieldMy Eighth Project: Robot Arm with Smart Tank Chassis and BluetoothMy Seventh Project: Robot Arm Set
Add instructable to: