Source: https://mokxi.com/learn/path/arduino-library-authoring
Updated: 2026-11-20

All paths

# Write your own Arduino library

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

Arduino Uno R3 Free 7 lessons 5 h 4 chapters 2,030 XP Coding · Intermediate +150 XP

0 of 7 done

Start the course free Header and .cpp Lesson plan for teachers

What you will build

## 3 projects, built step by step

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

Chapter 1 project

### 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.
Open it in the simulator

Chapter 2 project

### 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.
Open it in the simulator

Chapter 3 project

### 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.
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

## Files and a class

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

Open 218 XP

### 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.

0 of 6 steps

Start What is in it

Project Locked 472 XP

### 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.

0 of 6 steps

4 questions, graded as you go.

Chapter 2

## Made for people

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

Locked 187 XP

### 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.

0 of 5 steps

Project Locked 374 XP

### 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.

0 of 5 steps

4 questions, graded as you go.

Chapter 3

## Release it

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

Locked 187 XP

### 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.

0 of 5 steps

Project Locked 374 XP

### 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.

0 of 5 steps

4 questions, graded as you go.

Chapter 4

## Project

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

Locked 218 XP

### 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.

0 of 6 steps

3 questions, graded as you go.

Syllabus

## Every lesson in the course

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

Chapter 1

### Files and a class

- 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.
- 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.

Chapter 2

### Made for people

- 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.
- 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.

Chapter 3

### Release it

- 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.
- 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.

Chapter 4

### Project

- 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.

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 Write your own Arduino library

Is Write your own Arduino library free?

Yes. All 7 lessons of Write your own Arduino library 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 Write your own Arduino library take?

About 5 hours: 7 lessons in 4 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: Class design, Docs and keywords and Zip and share.

Where do I start?

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