Introduction: My Ninth Project: Robot Arm With Joystick Shield

Picture of My Ninth Project: Robot Arm With Joystick Shield

Although it is great controlling the robot arm with computer or mobile phone, I think using joystick is also cool, so I've bought a joystick shield and make a new project. This joystick shield is compatible with Arduino. It also support Nokia 5110 LCD module, nRF24L01 wireless module and Bluetooth module. It should be fun and convenient for various projects. : )

Step 1: Parts

Picture of Parts

Step 2: Assembly

Picture of Assembly

For assembling Robot Arm Set you can follow the manual downloaded from the link. You can also refer to my seventh project. For Joystick Shield it is very simple: There are pin headers that are compatible with Arduino, just plug this shield to the pins on Arduino UNO / MEGA and that's it.

Step 3: Wiring

Picture of Wiring

This is a continuation of the seventh project and the wiring between robot arm and servo controller is just the same.

For servo cable:

Brown = GND

Red = +

Orange = Signal

From servos to servo controller:

Servo at the base > S1

......

Servo at the claw > S6

Use extension wires if the servo cable is not long enough. Make sure all the cables are in correct direction.

For Battery:

Red wire of 7.4V Li-Po Battery > IN + of buck regulator

Black wire of 7.4V Li-Po Battery > IN - of buck regulator

For Buck Regulator

OUT + > VS of the blue terminal block on servo controller

OUT - > GND of the blue terminal block on servo controller

From servo controller to Joystick Shield

Pin GND > - on Joystick Shield

Pin 5V > + on Joystick Shield

RXD > Pin 0 on Joystick Shield

TXD > Pin 1 on Joystick Shield

Step 4: Testing Code

Next, I select A button to control the servo on the claw. When I press A button, the digital signal changes to 0 and the claw closes; when I release A button, the digital signal becomes 1 and the claw opens. I've referred to the table of PWM in the seventh project as follow:

Servo Lowest PWM Movement Highest PWM Movement

S1 500 right 2500 left

S2 500 up 2500 down

S3 500 down 2500 up

S4 500 down 2500 up

S5 500 anticlockwise 2500 clockwise

S6 900 open claw 1700 close claw

To control the servos with servo controller, we have to know the command and this is in the structure as follow:

#P ...........T

I want the claw closes in 1.5 second and we can sketch the code as follow:

#6P1700T1500

Servo controlling the claw is S6 and PWM of closing claw is 1700.

When I press A button, Arduino sends this command to servo controller via serial communication. Servo controller reads it and it instructs the claw to close.

int A_button = 2;

int B_button = 3;

int C_button = 4;

int D_button = 5;

int E_button = 6;

int F_button = 7;

int Analog = 8;

int x_axis = A0;

int y_axis = A1;

void setup()

{

Serial.begin(9600);

pinMode(A_button, INPUT);

pinMode(B_button, INPUT);

pinMode(C_button, INPUT);

pinMode(D_button, INPUT);

pinMode(E_button, INPUT);

pinMode(F_button, INPUT);

pinMode(Analog, INPUT);

}

void loop()

{

int A_button_state = digitalRead(A_button);

int B_button_state = digitalRead(B_button);

int C_button_state = digitalRead(C_button);

int D_button_state = digitalRead(D_button);

int E_button_state = digitalRead(E_button);

int F_button_state = digitalRead(F_button);

int Analog_state = digitalRead(Analog);

int x_axis_state = analogRead(x_axis);

int y_axis_state = analogRead(y_axis);

if (A_button_value == 1)

{

move(6, 900, 1500);

}

if (A_button_value == 0)

{

move(6, 1700, 1500);

}

}

void move(int servo, int position, int time)

{

Serial.print("#");

Serial.print(servo);

Serial.print("P");

Serial.print(position);

Serial.print("T");

Serial.println(time);

delay(time);

}

Before uploading this code, make sure both pin 0 and 1 are disconnected
from Joystick Shield. Otherwise the upload will fail. We can re-connect these two pins to Joystick Shield again after the sketch is uploaded.

Now you can control the claw by just pressing A button. You may also change the code in void loop() and test the buttons one by one.: D

Step 5: Modified Code

The test runs perfectly! But there is a problem: The claw opens when I release the button. If I wanna keep the claw closes, then I have to keep pressing the button. As a result, I place a value of PWM for each servo and add/minus 100 when I press the button.


int A_button = 2;

int B_button = 3;

int C_button = 4;

int D_button = 5;

int E_button = 6;

int F_button = 7;

int Analog = 8;

int x_axis = A0;

int y_axis = A1;

int value6 = 1000;

int value5 = 1000;

int value4 = 1000;

int value3 = 1000;

int value2 = 1000;

int value1 = 1000;

void setup()

{

Serial.begin(9600);

pinMode(A_button, INPUT);

pinMode(B_button, INPUT);

pinMode(C_button, INPUT);

pinMode(D_button, INPUT);

pinMode(E_button, INPUT);

pinMode(F_button, INPUT);

pinMode(Analog, INPUT);

}

void move(int servo, int position, int time)

{

Serial.print("#");

Serial.print(servo);

Serial.print("P");

Serial.print(position);

Serial.print("T");

Serial.println(time);

delay(time);

}

void loop()

{

int A_button_state = digitalRead(A_button);

int B_button_state = digitalRead(B_button);

int C_button_state = digitalRead(C_button);

int D_button_state = digitalRead(D_button);

int E_button_state = digitalRead(E_button);

int F_button_state = digitalRead(F_button);

int Analog_state = digitalRead(Analog);

int x_axis_state = analogRead(x_axis);

int y_axis_state = analogRead(y_axis);

x_axis_state = map(x_axis_state, 0, 1000, -1, 1);

y_axis_state = map(y_axis_state, 0, 1000, -1, 1);

if (A_button_state == LOW)

{

if (value6 < 1700)

{

value6 = value6 + 100;

move(6, value6, 100);

}

else

{

move(6, value6, 100);

}

}

if (B_button_state == LOW)

{

if (value6 > 900)

{

value6 = value6 - 100;

move(6, value6, 100);

}

}

if (C_button_state == LOW)

{

if (value5 < 2500)

{

value5 = value5 + 100;

move(5, value5, 100);

}

else

{

move(5, value5, 100);

}

}

if (D_button_state == LOW)

{

if (value5 > 500)

{

value5 = value5 - 100;

move(5, value5, 100);

}

}

if (E_button_state == LOW)

{

if (value4 < 2500)

{

value4 = value4 + 100;

move(4, value4, 100);

}

else

{

move(4, value4, 100);

}

}

if (F_button_state == LOW)

{

if (value4 > 500)

{

value4 = value4 - 100;

move(4, value4, 100);

}

}

if (Analog_state == LOW)

{

if (value3 < 2500)

{

value3 = value3 + 100;

move(3, value3, 100);

}

else

{

move(3, value3, 100);

}

}

if (y_axis_state == -1)

{

if (value2 < 2500)

{

value2 = value2 + 100;

move(2, value2, 100);

}

else

{

move(2, value2, 100);

}

}

if (y_axis_state == 1)

{

if (value2 > 500)

{

value2 = value2 - 100;

move(2, value2, 100);

}

}

if (x_axis_state == -1)

{

if (value1 < 2500)

{

value1 = value1 + 100;

move(1, value1, 100);

}

else

{

move(1, value1, 100);

}

}

if (x_axis_state == 1)

{

if (value1 > 500)

{

value1 = value1 - 100;

move(1, value1, 100);

}

}

}

Step 6: Result

After several modifications on the sketch (I have skipped several modifications as those results were not satisfied), finally I can control the robot arm with the Joystick Shield. Although I still haven't figured out some difficulties, e.g. I want to control both an increase and decrease of PWM on each servo with only one button, but in this project I have to do it with 2 buttons. It should be much simple to control it if I can find another way to encounter this problem. Please tell me if you know how to deal with it. Thanks a lot. : D

Comments

yichone (author)2017-06-01

also can use the wifi module DT-06, which is compatible with Bluetooth HC-06

Aneriah (author)2017-01-23

Could you please provide a detailed wiring diagram? The picture you provided are hard to read. And I always learn better with a picture.

Also I am a big fan of all of your projects and look forward to your next one.

ibenkos (author)2015-03-13

can you plz send me the link to the software download for the servo controller?

I can't find it anywhere :(

Rookie P (author)ibenkos2015-03-22

You can find it as follow : )

https://www.elabpeers.com/16-channel-servo-controller.html

ibenkos (author)Rookie P2015-03-23

thanks :)

airceo33 (author)2015-02-21

This is something ive been looking into doing. Awesome job. Can you help me with a project? I know its been done, but looking to do this controlled by wii nunchuck. If you can help id appreciate it!!!

Rookie P (author)airceo332015-03-22

You can make the shield youselves. I've also heard there is a small, cheap shield called wii nunchuck shield. Just buy it and connect it to your Arduino. However, as there is one joystick and two buttons on wii nunchuck only, it is limited in controlling 3 servos only, or restricted in particular motions, depending how to write the sketch.

ninjanody (author)2014-10-21

Nice... If u add bluetooth functionality too it will be awesome project..

Rookie P (author)ninjanody2014-10-25

It is a great idea. I will consider it seriously. :)

ibenkos (author)2014-10-18

Smart idea! Thanks for shearig :)

lewis.mwangi.33 (author)2014-10-09

COOL STUFF

leadzeplin (author)2014-10-08

Why don't you use a 9v battery instead of a Lipo battery. That way you would not need the buck regulator.

Rookie P (author)leadzeplin2014-10-08

As the operating voltage of servo is between 4.8V and 7.2V, using a 9V battery directly may be a problem.

awesomesauce72 (author)2014-10-03

it is cool and ive did it but y with the long audrino code

BLR_RAVI (author)2014-10-03

excellent work..i can feel that you have spend some time finding and fine tuning code...very nice to read .i liked it

seamster (author)2014-10-03

Cool!

About This Instructable

28,855views

359favorites

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: