A ₹1,470 two-link arm that goes to a point you type. Send “100 60” over the Serial Monitor and the sketch works out the shoulder and elbow angles that put the tip 100 mm out and 60 mm up. The page works through the geometry, shows a table of worked answers, checks whether small servos can hold the arm, and gives you a test plan to measure how far off the real arm is.
Scope: intermediate. This is a design worksheet with illustrative costs. It has not been bench-tested by this site. The angle maths on this page was checked by computing each answer and then running it forward again to confirm it lands on the target. The servo behaviour, the link lengths you build and the offsets you will need to trim are yours to measure. For a full three-axis arm with a torque table, see the 3-DOF robot arm; this build is the two-axis maths on its own, which is the part most people find confusing.
How it works
A two-link arm has a shoulder joint at the origin and an elbow joint at the end of the first link. The second link carries the tip. If the links are L1 and L2 long and the tip must reach (x, y), the distance from shoulder to target is r, where r² = x² + y². Two links can only reach a point when r is no more than L1 + L2 and no less than the difference of the two lengths. With two 80 mm links the reach is 160 mm.
The elbow angle comes from the cosine rule: cos(q2) = (x² + y² − L1² − L2²) / (2 × L1 × L2). Taking the arccos gives two answers, a positive and a negative angle. They are the same two-link arm in its two shapes, with the elbow above or below the line from shoulder to tip. Once q2 is known, the shoulder angle is q1 = atan2(y, x) − atan2(L2 × sin q2, L1 + L2 × cos q2). All angles are in radians inside the code and in degrees on the servos.
This page measures q1 from the horizontal, positive counter-clockwise, and q2 relative to the first link, positive counter-clockwise. With that convention a negative q2 puts the elbow above the line to the target (elbow-up), and a positive q2 puts it below. Pick one shape and keep it, otherwise the arm can flip between shapes in the middle of a move.
Bill of materials
| Part | Qty | Unit | Total |
|---|---|---|---|
| Arduino Uno clone | 1 | ₹550 | ₹550 |
| SG90-class servo | 2 | ₹130 | ₹260 |
| 80 mm arm link (cardboard, acrylic or printed) | 2 | ₹50 | ₹100 |
| 5 V 2 A buck converter | 1 | ₹220 | ₹220 |
| 2×18650 holder with cells | 1 | ₹200 | ₹200 |
| Switch | 1 | ₹30 | ₹30 |
| Jumper wire set | 1 | ₹50 | ₹50 |
| Small breadboard | 1 | ₹60 | ₹60 |
| Parts total | ₹1,470 | ||
Scroll the table sideways to see every column.
Prices checked Nov 2026. Shipping and tools are not included.
Prices are illustrative figures for Indian sellers in November 2026, before shipping, and have not been checked against current listings. Two servos are the only moving parts, so the cost sits in the board and the power supply, not the arm.
Worked examples
| Target (x, y) in mm | Elbow-up q1 / q2 | Elbow-down q1 / q2 | Usable on a 0–180° servo? |
|---|---|---|---|
| 100, 60 | 74.17° / −86.42° | −12.24° / 86.42° | Elbow-up only; elbow-down needs the shoulder below horizontal |
| 120, 40 | 56.20° / −75.52° | −19.33° / 75.52° | Elbow-up only |
| 150, 20 | 26.55° / −37.90° | −11.36° / 37.90° | Elbow-up only |
| 60, 90 | 103.77° / −94.93° | 8.84° / 94.93° | Neither, if the elbow servo is centred: it needs more than ±90° |
| 170, 0 | unreachable | unreachable | Beyond the 160 mm reach |
Two limits show up in the table. A hobby servo travels about 180 degrees, so a joint that has to bend more than 90 degrees either side of straight will not fit when its horn is centred. And a shoulder that has to point below horizontal needs the arm mounted high enough, or a servo horn fitted so the range moves down. Mount the shoulder so that servo angle 0 points along the +x axis and 90 points straight up; the sketch assumes that.
Can small servos hold it?
Here is the torque for a stretched, horizontal arm, which is the worst case. The assumptions are 12 g per link, a 20 g payload and 80 mm links. The elbow carries half of link two plus the payload at the tip: (0.012 × 0.040 + 0.020 × 0.080) kg·m × 9.81 = 0.0204 N·m, about 0.21 kgf·cm. The shoulder carries both links and the payload: (0.012 × 0.040 + 0.012 × 0.120 + 0.020 × 0.160) kg·m × 9.81 = 0.0502 N·m, about 0.51 kgf·cm.
SG90-class servos are commonly listed at a stall torque of about 1.8 kgf·cm at 4.8 V. That figure varies between makers and clones, and it is a stall number, not a comfortable working load. On these assumptions the shoulder needs about 28 percent of the listed figure. A sensible rule is to stay below about half, which this arm does, but weigh your own links and payload on a kitchen scale, because a heavy cardboard link or a metal gripper changes the answer quickly.
Power and wiring
| Part | Arduino Uno | Note |
|---|---|---|
| Shoulder servo signal | D9 | The Servo library takes over PWM on pins 9 and 10 |
| Elbow servo signal | D10 | See above |
| Servo VCC | Buck converter 5 V output | Not the Uno 5V pin |
| Servo GND | Common GND | Join the buck, Uno and servo grounds |
| Uno power | USB while testing | Use one source at a time |
Servos draw short bursts of current when they start moving. A servo powered from the Uno 5V pin on USB can reset the board; a separate rail with a shared ground avoids that. If the Uno restarts as the arm moves, the supply is the first suspect.
The sketch
// Two-link arm inverse kinematics: Uno + 2 servos
// Type "x y" in millimetres in the Serial Monitor (set to "Newline", 115200 baud).
// Design worksheet: trim OFFSET and SIGN to your own horn positions.
#include <Servo.h>
const float L1 = 80.0; // shoulder to elbow, mm
const float L2 = 80.0; // elbow to tip, mm
const int SHOULDER_PIN = 9;
const int ELBOW_PIN = 10;
const int SHOULDER_OFFSET = 0; // servo angle when link 1 points along +x
const int ELBOW_CENTRE = 90; // servo angle when link 2 is in line with link 1
const int ELBOW_SIGN = 1; // set to -1 if the elbow moves the wrong way
const int SERVO_MIN = 10; // keep clear of the end stops
const int SERVO_MAX = 170;
const bool ELBOW_UP = true; // negative q2
Servo shoulder;
Servo elbow;
float curS = 90;
float curE = 90;
bool solve(float x, float y, float &q1, float &q2) {
float c2 = (x * x + y * y - L1 * L1 - L2 * L2) / (2.0 * L1 * L2);
if (c2 < -1.0 || c2 > 1.0) return false; // out of reach
float s2 = sqrt(1.0 - c2 * c2);
if (ELBOW_UP) s2 = -s2;
q2 = atan2(s2, c2);
q1 = atan2(y, x) - atan2(L2 * s2, L1 + L2 * c2);
q1 *= RAD_TO_DEG;
q2 *= RAD_TO_DEG;
return true;
}
void moveTo(float s, float e) {
// Step one degree at a time so the arm does not snap to the target.
while (abs(curS - s) > 0.5 || abs(curE - e) > 0.5) {
if (curS < s) curS += 1; else if (curS > s) curS -= 1;
if (curE < e) curE += 1; else if (curE > e) curE -= 1;
shoulder.write((int)curS);
elbow.write((int)curE);
delay(15);
}
}
void setup() {
Serial.begin(115200);
Serial.setTimeout(50);
shoulder.attach(SHOULDER_PIN);
elbow.attach(ELBOW_PIN);
shoulder.write((int)curS);
elbow.write((int)curE);
Serial.println("Type: x y (mm)");
}
void loop() {
if (!Serial.available()) return;
String line = Serial.readStringUntil('\n');
line.trim();
int sp = line.indexOf(' ');
if (sp < 0) { Serial.println("Need two numbers"); return; }
float x = line.substring(0, sp).toFloat();
float y = line.substring(sp + 1).toFloat();
float q1, q2;
if (!solve(x, y, q1, q2)) { Serial.println("Out of reach"); return; }
float s = q1 + SHOULDER_OFFSET;
float e = ELBOW_CENTRE + ELBOW_SIGN * q2;
if (s < SERVO_MIN || s > SERVO_MAX || e < SERVO_MIN || e > SERVO_MAX) {
Serial.println("Needs more servo travel than allowed");
return;
}
Serial.print("q1="); Serial.print(q1);
Serial.print(" q2="); Serial.print(q2);
Serial.print(" servos "); Serial.print(s);
Serial.print(", "); Serial.println(e);
moveTo(s, e);
}The sketch refuses a target that is out of reach or that would push a servo past its limit, instead of driving into the end stop. It moves one degree at a time. The sign convention is the first thing to check on a new build: if typing a point above the arm moves the tip down, flip ELBOW_SIGN or the shoulder mounting, not the maths.
Test plan
- Centre first: before fitting the horns, power the servos at 90 degrees. Fit the shoulder link so it points straight up and the elbow link so it is in line with the first.
- Zero the shoulder: adjust SHOULDER_OFFSET until a command that should point link 1 along +x does so. Check with a ruler or a protractor taped to the base.
- Check the elbow direction: command a point that needs a bend and confirm the elbow bends toward the shape you chose. Flip ELBOW_SIGN if not.
- Measure link lengths: measure from joint centre to joint centre with a ruler and put the real values in L1 and L2. A few millimetres of error here becomes tip error everywhere.
- Grid test: tape squared paper to the table, put a pen or pointer on the tip, command ten points and record where the tip lands. Compute the error at each point.
- Repeatability: go to one point, move away, return, and mark each time. The spread is the repeatability; the offset from the target is the accuracy. Keep them separate, as in repeatability versus accuracy.
- Load: add the pen, gripper or sensor you plan to carry and check the servos hold it without buzzing.
What other builders report
This section summarises public material in our own words. None of it is our measurement, and where we could not open a source to confirm a detail, we say so.
- Hobby servos of the SG90 class are commonly described as accurate to only a few degrees because of gear backlash and potentiometer error. One low-authority blog gave 2 to 5 degrees; we could not open it to confirm, so treat that range as an assumption, not a specification.
- If your joint error is in that range, our arithmetic at the 160 mm full reach gives a tip error from the shoulder alone of about 160 × 0.035 = 5.6 mm for 2 degrees and about 14 mm for 5 degrees, before the elbow adds its own.
- On jitter, one forum thread describes an SG90 that twitched on the Arduino 5V pin. An external supply with a shared ground gave only a slight improvement, and what finally cured it was replacing the servo with a genuine SG90. So clone quality may matter as much as the supply.
- A university course page on a servo robot arm notes that the mapping from servo angle to link angle needs a calibration map in the code (CTU course notes); we only saw this in a search summary and did not read the page in full.
What this means for the build: calibrate each servo rather than trusting 0 to 180, keep targets away from the edge of the reach, and test your own pair of servos.
What usually goes wrong
| Symptom | Likely cause | Fix |
|---|---|---|
| Tip is off by the same amount everywhere | Link length or offset wrong | Re-measure L1 and L2, retrim the offsets |
| Error grows toward the edge of reach | Servo angle error is multiplied by link length | Calibrate offsets, accept a smaller working area |
| Arm flips shape between moves | Both solutions possible | Keep one shape and reject targets that need the other |
| Servo buzzes at a pose | Arm too heavy or past its limit | Lighten the links, narrow the limits |
| Board resets as it moves | Weak servo supply | Separate 5 V rail and a common ground |
| Jitter at rest | Supply noise | Add a capacitor across the servo rail, shorten the signal wires |
Upgrades
- Gripper: add the servo gripper and re-run the torque check with its weight.
- Smooth paths: move in a straight line by computing many intermediate points instead of one jump.
- Base rotation: add a third servo that turns the whole plane, and use the same maths in the arm plane. That is the step toward the 3-DOF arm.
- Drawing: hold a pen and trace a square to see how errors show up on paper.
Cost and parts notes
The ₹1,470 total is an illustration and does not include shipping. Servo clones differ in speed, torque and horn splines, so a spare is worth having. Use the cost calculator to compare sellers.
Common questions
What is inverse kinematics?
It is working out the joint angles needed to put a robot’s tip at a chosen point. Forward kinematics goes the other way, from angles to a point. This page uses both: inverse to command the arm, forward to check the answer.
Why are there two answers for each point?
A two-link arm can reach most points with the elbow above or below the line to the target. Both are valid; pick one shape and keep it.
Why did my target come back out of reach?
The distance from shoulder to target must lie between the difference and the sum of the two link lengths. With two 80 mm links the maximum is 160 mm.
Can I use different link lengths?
Yes. Change L1 and L2, re-run the torque check, and expect the reach and the servo load to change.
Last reviewed: November 2026. This is a design worksheet with illustrative costs. It has not been bench-tested by this site; library names, pins and limits must be checked against your board and the current library versions, and measurements from your build are welcome.