Source: https://mokxi.com/learn/path/inputs-in-depth
Updated: 2026-11-20

All paths

# Buttons, encoders, keypads and touch

Read people properly: button bounce on a scope and debouncing, clicks, double clicks and long presses, rotary encoders, matrix keypads, MPR121 touch and joysticks, then a retro game menu with a high score entry screen.

Arduino Uno R3 Free 7 lessons 6 h 4 chapters 2,229 XP Embedded engineering · Intermediate +150 XP

0 of 7 done

Start the course free Bounce on the scope, and debounce Lesson plan for teachers

What you will build

## 3 projects, built step by step

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

Chapter 1 project

### Long press and double click

Three gestures from one button: a state machine that waits a moment to tell a click from a double click, and reports a long press while the button is still held.
Open it in the simulator

Chapter 2 project

### Matrix keypads

Sixteen keys on eight pins: scanning rows and columns, pressed, held and released events from the Keypad library, two keys at once, and a door code typed into a buffer.
Open it in the simulator

Chapter 3 project

### Joysticks

Two potentiometers and a button that should feel right: centering at start-up, a dead zone, -100 to 100 per axis, direction events that repeat while held, and a fire button.
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

## Buttons

Bounce, debounce, and gestures from one button.

Open 218 XP

### Bounce on the scope, and debounce

One press, many edges: a scope on a bouncing pushbutton, an interrupt that counts every edge, and a debounce that waits for the contacts to settle before believing them.

0 of 6 steps

Start What is in it

Project Locked 436 XP

### Long press and double click

Three gestures from one button: a state machine that waits a moment to tell a click from a double click, and reports a long press while the button is still held.

0 of 6 steps

4 questions, graded as you go.

Chapter 2

## Knobs and keys

Rotary encoders and matrix keypads.

Locked 236 XP

### Rotary encoders

A knob that never ends: two contacts a quarter cycle apart, a state table that turns them into steps and a direction, interrupts so no step is missed, and bounce that the table shrugs off.

0 of 6 steps

Project Locked 436 XP

### Matrix keypads

Sixteen keys on eight pins: scanning rows and columns, pressed, held and released events from the Keypad library, two keys at once, and a door code typed into a buffer.

0 of 6 steps

4 questions, graded as you go.

Chapter 3

## Touch and sticks

Capacitive pads and analog joysticks.

Locked 218 XP

### MPR121 capacitive touch

Twelve touch pads on one I2C chip: capacitance that drops when a finger comes near, a baseline that tracks it, thresholds that decide a touch, and a note for each pad.

0 of 6 steps

Project Locked 436 XP

### Joysticks

Two potentiometers and a button that should feel right: centering at start-up, a dead zone, -100 to 100 per axis, direction events that repeat while held, and a fire button.

0 of 6 steps

3 questions, graded as you go.

Chapter 4

## Project

A retro game menu with a high score entry screen.

Locked 249 XP

### Project: a retro game menu

A Star Blaster arcade menu on a 16x2 LCD and a rotary encoder: scroll and press, a sound toggle, a high score table in EEPROM, and initials dialed in letter by letter.

0 of 7 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

### Buttons

- Bounce on the scope, and debounce One press, many edges: a scope on a bouncing pushbutton, an interrupt that counts every edge, and a debounce that waits for the contacts to settle before believing them.
- Long press and double click Three gestures from one button: a state machine that waits a moment to tell a click from a double click, and reports a long press while the button is still held.

Chapter 2

### Knobs and keys

- Rotary encoders A knob that never ends: two contacts a quarter cycle apart, a state table that turns them into steps and a direction, interrupts so no step is missed, and bounce that the table shrugs off.
- Matrix keypads Sixteen keys on eight pins: scanning rows and columns, pressed, held and released events from the Keypad library, two keys at once, and a door code typed into a buffer.

Chapter 3

### Touch and sticks

- MPR121 capacitive touch Twelve touch pads on one I2C chip: capacitance that drops when a finger comes near, a baseline that tracks it, thresholds that decide a touch, and a note for each pad.
- Joysticks Two potentiometers and a button that should feel right: centering at start-up, a dead zone, -100 to 100 per axis, direction events that repeat while held, and a fire button.

Chapter 4

### Project

- Project: a retro game menu A Star Blaster arcade menu on a 16x2 LCD and a rotary encoder: scroll and press, a sound toggle, a high score table in EEPROM, and initials dialed in letter by letter.

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 Buttons, encoders, keypads and touch

Is Buttons, encoders, keypads and touch free?

Yes. All 7 lessons of Buttons, encoders, keypads and touch 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 Buttons, encoders, keypads and touch take?

About 6 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: Long press and double click, Matrix keypads and Joysticks.

Where do I start?

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