Source: https://mokxi.com/learn/path/build-boat-autopilot
Updated: 2026-11-20

All paths

# Build a boat autopilot

A tiller pilot for the simulator: a tilt-compensated compass with declination, a limited rudder, a PID heading loop that knows 359 from 1 and ignores waves, and great-circle navigation to GPS waypoints. Never for real navigation.

Arduino Uno R3 Free 6 lessons 7 h 3 chapters 2,052 XP Robotics · Advanced +250 XP

0 of 6 done

Start the course free Heading from a compass Lesson plan for teachers

What you will build

## 3 projects, built step by step

6 lessons in 3 chapters, about 7 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Tilt compensation

A sailboat heels. Tip a flat compass and the vertical field leaks into its reading. Heel 20 degrees and watch north read 329, then see how the accelerometer puts it back.
Open it in the simulator

Chapter 2 project

### A PID heading loop

Close the loop: AUTO holds a course with a PID on the heading error. Turn to a new course, fall into the 359 to 1 trap and out of it, ride out a knock, and stop the rudder hunting in waves.
Open it in the simulator

Chapter 3 project

### Project: hold a course

Sail the whole route, add a leg of your own, steer it from the knob, and write up the pilot with its limits.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Which way is north

Heading from a three-axis compass, declination, and tilt compensation for a heeling boat.

Open 250 XP

### Heading from a compass

An LSM303AGR measures the Earth’s field in three axes. Turn two of them into a heading with atan2, keep it in 0 to 360, and correct magnetic north to true north with the declination.

0 of 5 steps

Start What is in it

Project Locked 424 XP

### Tilt compensation

A sailboat heels. Tip a flat compass and the vertical field leaks into its reading. Heel 20 degrees and watch north read 329, then see how the accelerometer puts it back.

0 of 4 steps

4 questions, graded as you go.

Chapter 2

## Steer

A rudder with limits, and a PID heading loop that wraps, recovers and does not hunt.

Locked 212 XP

### A rudder servo

The rudder is a servo with limits: 30 degrees each way and 40 degrees a second. Steer by hand in standby, hit the stop, watch the modeled boat turn, and slow the rudder to a real ram’s speed.

0 of 4 steps

Project Locked 576 XP

### A PID heading loop

Close the loop: AUTO holds a course with a PID on the heading error. Turn to a new course, fall into the 359 to 1 trap and out of it, ride out a knock, and stop the rudder hunting in waves.

0 of 6 steps

4 questions, graded as you go.

Chapter 3

## Navigate

Great-circle distance and bearing to waypoints, then the whole route.

Locked 212 XP

### GPS waypoints

From holding a heading to going somewhere. Get a fix, work out great-circle distance and bearing to a waypoint, steer to it, and switch to the next one inside an arrival radius.

0 of 4 steps

Project Locked 378 XP

### Project: hold a course

Sail the whole route, add a leg of your own, steer it from the knob, and write up the pilot with its limits.

0 of 4 steps

3 questions, graded as you go.

Syllabus

## Every lesson in the course

All 6 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Which way is north

- Heading from a compass An LSM303AGR measures the Earth’s field in three axes. Turn two of them into a heading with atan2, keep it in 0 to 360, and correct magnetic north to true north with the declination.
- Tilt compensation A sailboat heels. Tip a flat compass and the vertical field leaks into its reading. Heel 20 degrees and watch north read 329, then see how the accelerometer puts it back.

Chapter 2

### Steer

- A rudder servo The rudder is a servo with limits: 30 degrees each way and 40 degrees a second. Steer by hand in standby, hit the stop, watch the modeled boat turn, and slow the rudder to a real ram’s speed.
- A PID heading loop Close the loop: AUTO holds a course with a PID on the heading error. Turn to a new course, fall into the 359 to 1 trap and out of it, ride out a knock, and stop the rudder hunting in waves.

Chapter 3

### Navigate

- GPS waypoints From holding a heading to going somewhere. Get a fix, work out great-circle distance and bearing to a waypoint, steer to it, and switch to the next one inside an arrival radius.
- Project: hold a course Sail the whole route, add a leg of your own, steer it from the knob, and write up the pilot with its limits.

Keep going

## The next course on your track

Build a boat autopilot is part of the maker track, a ladder of courses from zero to expert.

Next course

### Build a cornhole scoreboard

Big digits, team buttons, real cancellation scoring to 21, a radio remote on a second Uno and a fanfare for the winners.
Open the next course

Track

### Maker track

Follow the starter kit you already own, then build a claw machine, a balance bot, a handheld console or an LED cube, each a short course checked by the simulator.
See every course on the track

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Build a boat autopilot

Is Build a boat autopilot free?

Yes. All 6 lessons of Build a boat autopilot are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Build a boat autopilot take?

About 7 hours: 6 lessons in 3 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Tilt compensation, A PID heading loop and Project: hold a course.

Where do I start?

With "Heading from a compass", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
