Joystick Controlled Robot Arm Using An Arduino
Joystick Controlled Robot Arm Using An Arduino
instructables.com/Joystick-Controlled-Robot-Arm-Using-an-Arduino
This instructable is a hand-in for a school project that we made. The purpose of this project was to
create a robot arm control using thumbsticks. We had to use an Arduino Uno for the control and in
addition, we had to implement some sort of actuator or sensor in the setup. We modified a Logitech
gamepad using the two thumbsticks. Two push buttons where available to use, but only one activates
the magnet (on L3), and the button on R3 is unused. Our school had a robot arm, a Logitech
gamepad controller, an electromagnet and two thumbsticks made available to us.
1/9
2/9
3 More Images
This is what the gamepad looked like before modification. Since we decided that thumbsticks where
the way to go, we had to cut away and replace the gut of the gamepad [First picture].
We modified the gamepad, so it had to thumbsticks instead of a d-pad and command buttons. We
soldered the thumbsticks on a PCB board and wired them. Two 10K Ohm resistors where also
soldered to the push buttons of the thumbsticks [2nd - 5th picture].
We made two large holes on the front panel, so the two thumbsticks would fit in [Last picture].
3/9
For full details open picture in full screen.
4/9
#include <Servo.h>
void setup()
{
pinMode(3, INPUT); /* Use button on thumbstick to set pin 3 as input */
pinMode(4, OUTPUT); /* Set pin 4 as output to the magnet */
void loop()
{
// read analog values from joysticks
value1 = analogRead(pin0);
value2 = analogRead(pin1);
value3 = analogRead(pin2);
value4 = analogRead(pin3);
// 10 bit value is too big, so we change the scale from 0 - 1023 proportionately to 1 - 29
5/9
value1 = map(value1, 0, 1023, 1, 29);
value2 = map(value2, 0, 1023, 1, 29);
value3 = map(value3, 0, 1023, 1, 29);
value4 = map(value4, 0, 1023, 1, 29);
// it needs correction of positions, because joysticks are not very precise to stay exactly
in the center
if(value1 <= 17 && value1 >= 13) // if value1 if between 13-17, then it's equal to 15 */
value1 = 15;
if(value2 <= 17 && value2 >= 13)
value2 = 15;
if(value3 <= 17 && value3 >= 13)
value3 = 15;
if(value4 <= 17 && value4 >= 13)
value4 = 15;
// Change initial value 'forservo' which is used to turn servo slower. This value has got
very big scale.
// We add or substract (depends on turning direction) difference between analog value and
center from 'forservo'
forservo1 = forservo1 - (value1 - 15);
forservo2 = forservo2 - (value2 - 15);
forservo3 = forservo3 + (value3 - 15);
forservo4 = forservo4 + (value4 - 15);
// change used value to angle of servo. Angles are adjusted during testing
angle1 = map(forservo1, 1, 20000, 10, 180);
angle2 = map(forservo2, 1, 20000, 10, 180);
angle3 = map(forservo3, 1, 20000, 10, 180);
angle4 = map(forservo4, 1, 20000, 10, 180);
6/9
servo2.write(angle2);
servo3.write(angle3);
servo4.write(angle4);
7/9
Step 6: Result (video)
8/9
Watch Video At: https://youtu.be/_4mCApUtNoA
9/9