Source: https://mokxi.com/teachers/plans/keyboard-matrix
Updated: 2026-11-11

Lesson plan

# Custom keyboards from the matrix up lesson plan

Scan a key matrix, see ghosting and the diode that stops it, then add layers, a knob and per-key light.

2 chapters, 3 lessons, about 3 hours, on the SparkFun Pro Micro. 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

- Rows, columns, the scan, and why every key gets a diode.
- A layered keymap, an encoder and one LED per key.

### Materials for the whole unit

- Addressable RGB LEDs
- Diode x 12
- Full-size breadboard
- Half breadboard x 4
- Keypad, 4x4
- Pushbutton x 12
- Rotary encoder, KY-040
- SparkFun Pro Micro

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 50 min

## The matrix

Rows, columns, the scan, and why every key gets a diode.

Lesson | Time | What students do

Rows, columns and the scan Why twelve keys need only seven pins: drive one row LOW at a time, read the columns, and find every key by its row and column. | 55 min

- Why a keyboard is a matrix
- Press a key
- Watch the scan on a column
- Any key, by its row and column
- Three keys on a rectangle

Ghosting, and why every key gets a diode Scan a membrane keypad that has no diodes, hold three keys on a rectangle and watch a fourth appear, then see how one diode per key stops it. | 55 min

- A matrix with nothing in it
- One key reads true
- The key that is not there
- Another rectangle
- One diode per key

### Materials

- Addressable RGB LEDs
- Diode x 12
- Full-size breadboard
- Half breadboard x 4
- Keypad, 4x4
- Pushbutton x 12
- Rotary encoder, KY-040
- SparkFun Pro Micro

### Check for understanding

Each student finishes "Ghosting, and why every key gets a diode" 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: "One diode per key".

Chapter 2. About 1 h 10 min

## The keyboard

A layered keymap, an encoder and one LED per key.

Lesson | Time | What students do

Layers, a knob and per-key light Turn the matrix into a keyboard: a keymap with layers you hold and toggle, an encoder that scrolls or steps by layer, and one WS2812B per key. | 70 min

- A keymap is a table
- Type a key
- Hold a layer
- The knob, by layer
- One LED per key
- From here to QMK or KMK

### Materials

- Addressable RGB LEDs
- Diode x 12
- Half breadboard x 4
- Pushbutton x 12
- Rotary encoder, KY-040
- SparkFun Pro Micro

### Check for understanding

Each student finishes "Layers, a knob and per-key light" 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: "From here to QMK or KMK".

Your class

## Teach this unit as a class

Start a class from this course and its 3 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.
