Source: https://mokxi.com/learn/path/fix-the-bug
Updated: 2026-11-11

All paths

# Fix the bug

Short puzzles on an Uno: one planted fault each, in the wiring or the code. Find it, fix it, and see it work.

Arduino Uno R3 Free 8 lessons 1 h 2 chapters 1,470 XP Coding · Intermediate +150 XP

0 of 8 done

Start the course free The LED that never lights Lesson plan for teachers

What you will build

## 2 projects, built step by step

8 lessons in 2 chapters, about 1 hour on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### The button on the wrong pin

The sketch reads a button on pin 2 and lights the LED. Hold the button and nothing happens. Find out why.
Open it in the simulator

Chapter 2 project

### The if that always runs

The LED should light only while the button is held, and it is on all the time. One character is to blame.
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

## Wiring faults

A missing wire, a missing ground, and a wire on the wrong pin.

Open 156 XP

### The LED that never lights

Blink is running, pin 13 is switching, and the LED on the breadboard stays dark. Find the gap in the loop.

0 of 4 steps

Start What is in it

Locked 156 XP

### The board with no ground

Pin 13 is high, the LED and resistor are wired to the rail, and nothing lights. Find what the loop is missing.

0 of 4 steps

Project Locked 276 XP

### The button on the wrong pin

The sketch reads a button on pin 2 and lights the LED. Hold the button and nothing happens. Find out why.

0 of 4 steps

Chapter 2

## Code faults

A copied line, a missing pinMode, an upside-down test, an off-by-one and a stray semicolon.

Locked 138 XP

### The blink that stays on

A blink sketch with two writes and two delays, and an LED that comes on and never goes off. Read the loop.

0 of 4 steps

Locked 138 XP

### The output that is not an output

digitalWrite says HIGH and the LED barely glows. The loop is fine. Find what setup() leaves out.

0 of 4 steps

Locked 156 XP

### The lamp that is on until you press

The LED should light while the button is held. It is lit with the button up and goes dark when you press.

0 of 4 steps

Locked 138 XP

### The count that stops at nine

A for loop that should print 1 to 10 prints 1 to 9 and says done. Find where ten went.

0 of 4 steps

Project Locked 312 XP

### The if that always runs

The LED should light only while the button is held, and it is on all the time. One character is to blame.

0 of 4 steps

Syllabus

## Every lesson in the course

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

Chapter 1

### Wiring faults

- The LED that never lights Blink is running, pin 13 is switching, and the LED on the breadboard stays dark. Find the gap in the loop.
- The board with no ground Pin 13 is high, the LED and resistor are wired to the rail, and nothing lights. Find what the loop is missing.
- The button on the wrong pin The sketch reads a button on pin 2 and lights the LED. Hold the button and nothing happens. Find out why.

Chapter 2

### Code faults

- The blink that stays on A blink sketch with two writes and two delays, and an LED that comes on and never goes off. Read the loop.
- The output that is not an output digitalWrite says HIGH and the LED barely glows. The loop is fine. Find what setup() leaves out.
- The lamp that is on until you press The LED should light while the button is held. It is lit with the button up and goes dark when you press.
- The count that stops at nine A for loop that should print 1 to 10 prints 1 to 9 and says done. Find where ten went.
- The if that always runs The LED should light only while the button is held, and it is on all the time. One character is to blame.

Keep going

## The next course on your track

Fix the bug is part of the coding track, a ladder of courses from zero to expert.

Next course

### C++ that scales

The habits that keep a big program sane, on the Uno: references and const, classes, a ring buffer, a state machine class, templates, and logic split from pins so it tests itself. Ends with a tested calculator.
Open the next course

Track

### Coding track

Python and C++ from your first print to classes, tests and state machines. Every program runs on a simulated board, so a bug is something you can see.
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 Fix the bug

Is Fix the bug free?

Yes. All 8 lessons of Fix the bug 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 Fix the bug take?

About 1 hour: 8 lessons in 2 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: The button on the wrong pin and The if that always runs.

Where do I start?

With "The LED that never lights", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
