I turned a kit into a fully controllable robot arm, with custom firmware, inverse kinematics, 3D simulation and a web interface for defining points and paths.
The demo uses the same inverse kinematics as the real software: you set a target point, and the program works out how the joints need to be positioned.
The software that came with the kit was only a simple remote control. So I rewrote both the firmware and the PC software from scratch.
You enter X, Y and Z in millimetres, and the software calculates the joint angles. The gripper stays level throughout.
A live 3D view always shows the arm's current pose. I programmed it myself, without third-party libraries.
Positions can be saved and revisited. Waypoints, pauses and tool actions combine into complete sequences, which can also run in a loop.
Moves end before the mechanical stops, and unreachable targets are rejected. STOP halts, the emergency stop switches the motors off.
On the rotary axis, a light barrier replaces the mechanical limit switch.
I first decoded the original firmware's protocol by disassembling its machine code. Today the arm runs completely custom firmware.
Ten guided steps check limit switches and directions and calibrate the arm.
All axes start and stop together; none runs ahead.
If you like, an ESP32 replaces the USB cable with a Wi-Fi link.
Everything runs locally on your own computer, with no cloud and no heavy add-on packages.
An Arduino Mega 2560 with a RAMPS 1.4 shield drives three stepper motors for the joints and one for the rail. On the rotary axis, a light barrier sits instead of a limit switch, so the axis can safely spin through.
| Function | Connection (RAMPS) | Pin |
|---|---|---|
| Main arm (X, joint 1) | Y driver slot | STEP/DIR/EN |
| Forearm (Y, joint 2) | X driver slot | STEP/DIR/EN |
| Rotary axis (Z) | Z driver slot | STEP/DIR/EN |
| Linear rail (E) | E0 driver | STEP/DIR/EN |
| Limit switch, forearm | X-min | D3 |
| Limit switch, main arm | Y-min | D14 |
| Light barrier, rotary axis | Z-min (S/−/+) | D18 |
| Gripper / suction cup / fan | FET outputs | D9 / D10 / D8 |
| ESP32 Wi-Fi bridge (optional) | AUX-4 (Serial2) | D16 TX2 / D17 RX2 |
| Power supply | Power supply unit | 12 V DC |
You specify a point in space, and the arm sets its joints by itself so that it reaches it. This method is called inverse kinematics. For an arm with two joints on a turntable, it can be solved exactly.
First the turntable rotates until the target lies in the plane of the arm:
Reach r and height z give the distance d. The law of cosines gives the arm angles:
If d is greater than a + b or less than |a − b|, the target is unreachable. The software then does not move.
The forward kinematics calculates the real position back from the joint angles. That way the 3D view always shows where the arm is.
Six steps from installation to your first program.
Install Python 3, run pip install pyserial once and then start Start_Windows.bat. The interface opens in the browser at localhost:8000.
In the Arduino IDE, install the library AccelStepper. Then open RobotArmFW.ino, select the board “Mega 2560” and upload the firmware.
Select the port (USB or “ESP32-Brücke”) and connect. Use M119 to test the limit switches; the light barrier then reports “interrupted = 1”. Only after that, make small jog steps.
With G28 each axis moves to its limit switch and sets the zero point there. You can abort with STOP (button or !) or with the emergency stop (space bar).
The assistant guides through calibration in ten steps. Then the limits before the stops are taught.
Moves end before the calibrated limits, and unreachable targets are rejected. STOP halts, and the motors stay energised. The emergency stop switches them off.
| Command | Function |
|---|---|
| G0 / G1 X Y Z E F [S0] | Axis move, all axes in sync; S0 moves them independently |
| G4 S<s> | Pause / dwell time |
| G28 [X Y Z] | Homing (can be aborted) |
| G90 / G91 | Absolute / relative mode |
| G92 X Y Z E | set current position |
| M17 / M18 | motors on / off |
| M42 P<pin> S<0..255> | switch output (gripper/suction cup/fan) |
| ! | STOP: aborts any movement; the motors stay energised |
| M112 | Emergency stop: halts immediately and switches the motors off |
| M114 | report position |
| M119 | report limit switch states |
The complete guide is included in the download as
FIRMWARE_ANLEITUNG.md and LIESMICH.md files.
The images show poses from the 3D simulation.
This excerpt shows how a target point becomes joint angles: trigonometry for the two arm joints plus a rotation of the base.
def cart_to_joints(self, x, y, z, e): # world coordinates [mm] -> joint angles of the parallelogram arm a, b = g["lower_arm"], g["upper_arm"] dx = x - e # arm base sits on the rail base = math.degrees(math.atan2(dx, y)) # base rotation r = math.hypot(dx, y) - g["tool_offset_h"] # reach h = z + g["tool_offset_v"] - g["base_height"] # height above shoulder d = math.hypot(r, h) if d > a + b: raise ValueError("point too far away") th1 = math.atan2(h, r) + math.acos((a*a + d*d - b*b) / (2*a*d)) # main arm th2 = math.atan2(h - a*math.sin(th1), r - a*math.cos(th1)) # forearm, absolute # … check angle limits and scissor angle, convert to joint units return joints, angles
As coordinates, the letters X, Y and Z mean something different than in G-code. Click a row to highlight that axis in the picture.
| Letter | As a coordinate | As a joint (G-code) |
|---|---|---|
X | left / right in mm | Main arm angle (joint 1) |
Y | forward / back in mm | Forearm angle (joint 2) |
Z | Height in mm | Base rotation |
E | - | Rail in mm |
A G1 Z50 does not move 50 mm upwards; it rotates the base. For height, use the Cartesian jog or the coordinate input.
If all joints turn evenly, the tip moves in an arc. For a true straight line, the path is split into small steps and the inverse kinematics is calculated for each and every one of them. In the demo you can compare both approaches.
Firmware, control software and guides come in one package. The software runs on any PC with Python.
⭳ Request ArmControl.zipWrite to me if you have questions about how it is built, would like to know why I solved something a certain way, or want to use the controller for an arm of your own.