Advanced8–12 h (estimate, mostly tuning)7 parts

PID ball-and-beam balancer

Keep a ping-pong ball at a set distance on a servo-tilted beam.

Overview

A beam pivots in the middle and a servo tilts it. An ultrasonic sensor at one end measures where the ball is. A PID controller turns the position error into a beam angle so the ball rolls to the setpoint and stays there.

It is a classic control lab because the ball accelerates whenever the beam is tilted, so P alone oscillates: you will need D for damping, a filter for the noisy distance readings, and limits on the beam angle.

You will learn

  • · Tuning a real PID loop (P, then D, then a little I)
  • · Filtering noisy feedback without adding too much lag
  • · Output limits and anti-windup
  • · Fixed-rate control loops with millis()

Parts list

Part (generic)QtyNote
Arduino Uno-compatible board (5 V logic)1
Standard hobby servo (metal gears recommended)1
Ultrasonic distance sensor module (HC-SR04-type, 5 V)1Readings on a small round ball are noisy; filtering is part of the build.
Straight beam with side rails or a U-channel, about 30–40 cm1
Ping-pong ball1
Pivot (hinge or bolt through a bracket), linkage rod, base1 set
Separate 5 V servo supply with a capacitor across it1

Generic part names only. Pinouts and logic levels vary between modules of the same type, so check the documentation of the exact module you have.

Tools

  • · USB cable and the Arduino IDE (Serial Plotter)
  • · Drill and saw for the frame
  • · Ruler
  • · Spirit level

Safety

  • · Clamp the frame to the table; the beam can flick the ball off quickly.
  • · Start with small angle limits until the loop is tuned.

Learn the ideas first

Full build

  1. 01Build the beam, pivot and servo linkage
  2. 02Measure ball position and filter it
  3. 03Find the level angle and set angle limits
  4. 04P control (expect oscillation)
  5. 05Add D for damping, then a little I
  6. 06Tune with the Serial Plotter and record step responses

Checking your account…