← Back to projects
PROJECT / 10Personal lab
Robotic arm: servo control
A two-joint model for testing positions.
WEB PROTOTYPE
Move two joint angles and inspect the calculated position. This is a geometric simulation with no physical Arduino connection.
View concept code
export function arm(base, elbow) {
if (![base, elbow].every((n) => Number.isFinite(n) && n >= 15 && n <= 165))
throw Error('Invalid angle');
const a = ((base - 90) * Math.PI) / 180,
b = a + ((elbow - 90) * Math.PI) / 180;
const joint = { x: 80 * Math.sin(a), y: 80 * Math.cos(a) };
return { joint, tip: { x: joint.x + 65 * Math.sin(b), y: joint.y + 65 * Math.cos(b) } };
}