Source: https://mokxi.com/teachers/plans/arduino-library-authoring
Updated: 2026-11-19

Lesson plan

# Write your own Arduino library lesson plan

Write TinyDigits, a TM1637 display driver, from the datasheet up: header and .cpp, a class, examples, docs, versions and a zip anyone can install.

4 chapters, 7 lessons, about 5 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- One tab becomes a header and a .cpp, then a class with a real API.
- Examples people copy, and docs and keywords that tell the truth.
- Version numbers that mean something, and a zip anyone can install.
- A mission clock on your library, and a minor release that says GO.

### Materials for the whole unit

- Arduino Uno R3
- Four-digit display, TM1637
- Full-size breadboard
- LED x 3
- Piezo speaker
- Pushbutton x 3
- Resistor x 3

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 30 min

## Files and a class

One tab becomes a header and a .cpp, then a class with a real API.

Lesson | Time | What students do

Header and .cpp A TM1637 driver bit-banged from the datasheet and a launch countdown, all in one tab. Split it into TinyDigits.h, which says what it does, and TinyDigits.cpp, which says how, and meet the one-definition rule. | 45 min

- Run it: a launch clock
- How a byte gets across
- The header: what it does
- The .cpp: how it does it
- One definition, many declarations
- What goes where

Class design TinyDigits as a class: a constructor that touches no hardware, begin() that reports whether anything answered, methods that refuse what they cannot do, a new method, a default argument, and two displays from one class. | 45 min

- Run it: three tabs and a class
- A constructor that waits
- Refuse, do not guess
- Add a method: showTime
- A default argument
- Two displays, one class

### Materials

- Arduino Uno R3
- Four-digit display, TM1637
- Full-size breadboard
- LED x 3
- Piezo speaker
- Pushbutton x 3
- Resistor x 3

### Check for understanding

Each student finishes "Class design" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Two displays, one class".

Chapter 2. About 1 h 20 min

## Made for people

Examples people copy, and docs and keywords that tell the truth.

Lesson | Time | What students do

Examples A library is judged by its examples. Replace a kitchen-sink demo with three that each teach one thing: HelloDigits, a button Countdown, and a SelfTest people run first when something is wrong. | 40 min

- Run it: the kitchen sink
- HelloDigits: the smallest example
- Countdown: one real use
- SelfTest: the first thing people run
- The example checklist

Docs and keywords Doc comments that state ranges and failure cases, a console that prints help from the library's own constants, a doc that promises more than the code can do, and keywords.txt for the IDE. | 40 min

- Run it: a console
- Help that cannot go stale
- A promise the code cannot keep
- Fix the promise
- keywords.txt and a README

### Materials

- Arduino Uno R3
- Four-digit display, TM1637
- Full-size breadboard
- LED x 3
- Piezo speaker
- Pushbutton x 3
- Resistor x 3

### Check for understanding

Each student finishes "Docs and keywords" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "keywords.txt and a README".

Chapter 3. About 1 h 20 min

## Release it

Version numbers that mean something, and a zip anyone can install.

Lesson | Time | What students do

Versioning Semantic versioning with numbers a sketch can test in #if: feature detection, a patch release for a bug that blanked zero, and a breaking change that earns a new major version. | 40 min

- Run it: three numbers
- Feature detection
- A patch release
- A breaking change
- Which number moves?

Zip and share The Arduino library layout, library.properties built from the header so the version lives in one place, a release check that refuses to ship, and the zip that installs in Mokxi and the Arduino IDE alike. | 40 min

- Run it: not ready to ship
- library.properties
- Problem 1: two versions
- Problem 2: say what it is
- Zip it and install it

### Materials

- Arduino Uno R3
- Four-digit display, TM1637
- Full-size breadboard
- LED x 3
- Piezo speaker
- Pushbutton x 3
- Resistor x 3

### Check for understanding

Each student finishes "Zip and share" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Zip it and install it".

Chapter 4. About 45 min

## Project

A mission clock on your library, and a minor release that says GO.

Lesson | Time | What students do

Project: a library for a part A mission clock built on TinyDigits: a launch countdown with START, HOLD and RESET buttons and three lamps. Then add showText to the library as a minor release and make the clock say GO. | 45 min

- Run it: mission clock
- Launch
- Hold the count
- A minor release: showText
- Make it yours
- Ship it

### Materials

- Arduino Uno R3
- Four-digit display, TM1637
- Full-size breadboard
- LED x 3
- Piezo speaker
- Pushbutton x 3
- Resistor x 3

### Check for understanding

Each student finishes "Project: a library for a part" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Ship it".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
