Robot Arm with Arduino Servos
Build a 4-DOF robotic arm using servo motors controlled by Arduino with joystick or Bluetooth control.
Parts List
- Arduino Uno
- SG90 Servo Motors (x4)
- Robot Arm Kit (3D printed or purchased)
- Joystick Module
- Breadboard
- External Power Supply (5V 3A)
Step-by-Step Instructions
Assemble Arm Structure
If using a 3D printed kit, print all arm segments using PLA filament at 20% infill for a good strength-to-weight ratio. Assemble the base, shoulder, elbow, and gripper joints using the provided screws and hardware. Sand any rough edges and test-fit each joint to ensure smooth movement before installing the servos.
Mount Servos
Install the SG90 servo motors at each joint, starting with the base rotation servo mounted to the platform. Attach the shoulder servo to the base arm, the elbow servo to the upper arm, and the gripper servo at the end effector. Use servo mounting brackets or hot glue to secure each motor firmly while ensuring the servo horns align with the joint axes.
Wire to Arduino
Connect each servo's signal wire to Arduino PWM pins: base to pin 3, shoulder to pin 5, elbow to pin 6, and gripper to pin 9. Wire all servo VCC pins to the external 5V power supply rather than the Arduino's 5V pin to prevent brownouts. Connect the joystick module to analog pins A0 (X-axis) and A1 (Y-axis) for directional control.
Write Control Code
Write an Arduino sketch that reads joystick values and maps them to servo angle changes with a smoothing filter to prevent jittery movement. Implement a calibration routine that centers each servo at 90 degrees when the joystick is released. Add speed control by scaling the servo angle increment based on joystick deflection, allowing both slow precise movements and fast sweeping motions.
#include <Servo.h>
Servo base, shoulder, elbow, gripper;
int baseAng = 90, shoulderAng = 90, elbowAng = 90;
void setup() {
base.attach(3);
shoulder.attach(5);
elbow.attach(6);
gripper.attach(9);
}
void loop() {
int xVal = analogRead(A0) - 512;
int yVal = analogRead(A1) - 512;
if (abs(xVal) > 20) {
baseAng = constrain(baseAng + xVal / 50, 0, 180);
base.write(baseAng);
}
if (abs(yVal) > 20) {
shoulderAng = constrain(shoulderAng + yVal / 50, 0, 180);
shoulder.write(shoulderAng);
}
delay(20);
}