← Back to Projects

Inverse Kinematics on Arduino: 6-DoF Robotic Arm

3D coordinate-based motion control and servo actuation using C++ on Arduino Uno

Arduino Uno C++ Servo Control 2025
6-DoF Robotic Arm with Arduino Uno and MG996R servos

Project Overview

This project implements inverse kinematics (IK) for a six-degree-of-freedom robotic arm controlled by an Arduino Uno. The system computes the joint angles needed to position the gripper in 3D space and tilt it to a defined global Z-axis angle.

Development Goals

The main goals were to learn practical robotics kinematics, build a modular embedded software architecture, and implement 3D coordinate-based servo control within the Arduino’s limited resources.

Hardware Setup

The PCA9685 module communicates via I²C and provides independent PWM signals for each servo. An external 5 V supply powers the motors safely, while the Arduino handles only logic control.

Software Architecture

The firmware is fully modular and divided into three main components:

Each module is independent, making the system easy to extend (e.g., adding sensor feedback or trajectory planning later).

Inverse Kinematics Implementation

The IK solver uses geometric relationships between link lengths and angles to find a valid set of joint positions for a given target. The model includes real-world offsets and measured angle corrections for physical servo mounting differences.

// Example from ik_solver.cpp
Angles solveIK(float x, float y, float z, float wristTilt, float wristRotate) {
  Angles a;
  a.theta0 = atan2(y, x);      // base rotation
  // project wrist length and solve shoulder/elbow geometry
  // includes measured link lengths: L1–L5
  ...
  return a;
}

The system currently supports up to four active degrees of freedom (Base, Shoulder, Elbow, Wrist Tilt) and calculates the gripper orientation relative to the global Z-axis.

Servo Control & Serial Interface

Each servo is smoothly interpolated between angles to avoid jerky movements. Commands are sent over USB as simple text lines:

GOTO X=150 Y=0 Z=120 TILT=90 ROTATE=90
GRIP OPEN
GRIP CLOSE

The firmware validates coordinate reachability and servo limits before movement to ensure safe operation.

Mechanical Model

Link lengths and offsets used in the calculation:

All coordinates are interpreted in a right-handed 3D coordinate system with the base as the origin.

Results & Lessons Learned

This project was a practical exercise in applying mathematics and embedded software to a real mechanical system. It highlighted the value of step-wise development — starting from 2D IK, then expanding to 3D and adding wrist control — to manage complexity and ensure reliability.

Source Code & Documentation

All source files and a detailed technical report are available on GitHub.

View on GitHub →

← Back to Projects