Source: https://mokxi.com/teachers/plans/registers-and-assembly
Updated: 2026-11-11

Lesson plan

# Under the hood lesson plan

Take the Arduino wrapper off: DDR, PORT and PIN, Timer 1 by hand, the vector table and interrupts, cycle-counted delays in a .S file, a bug read off a halt in the debugger, and a UART drawn by hand on a pin.

4 chapters, 6 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

- Pins and a timer, written register by register.
- The vector table and handlers that run while loop() sleeps.
- Count cycles in a .S file, and read a halted board.
- A UART frame drawn by hand on a plain pin.

### Materials for the whole unit

- Arduino Mega 2560 R3
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Logic analyzer, four channels
- Pushbutton
- 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 40 min

## Registers

Pins and a timer, written register by register.

Lesson | Time | What students do

DDR, PORT and PIN The three registers behind every digital pin: count in binary on three lamps with one write to PORTB, turn on a pull-up through PORTD, and read a button straight out of PIND. | 50 min

- Run it: no pinMode anywhere
- PORT on an input is the pull-up
- One write, three lamps
- Read PIN
- Count faster
- Find it in the data sheet

Timers by hand Timer 1 set up register by register: a prescaler, CTC mode and OCR1A for a match every 500 ms, the compare flag polled and cleared by hand, and no millis() anywhere. | 50 min

- Run it: a blink with no millis()
- The arithmetic
- Wait for the flag
- Read the counter
- Ten times a second
- Your own period

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Timers by hand" 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: "Your own period".

Chapter 2. About 50 min

## Interrupts

The vector table and handlers that run while loop() sleeps.

Lesson | Time | What students do

The vector table and interrupts The 26 jumps at the start of flash, read out of the chip itself: a Timer 1 interrupt that blinks while loop() sleeps, an INT0 handler that counts presses, volatile, and reading shared data safely. | 50 min

- Run it: read the table
- An interrupt blinks while loop() sleeps
- Count presses in INT0
- volatile, and reading safely
- Switch one interrupt off
- Which vector is which

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "The vector table and interrupts" 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: "Which vector is which".

Chapter 3. About 1 h 35 min

## Assembly and the debugger

Count cycles in a .S file, and read a halted board.

Lesson | Time | What students do

Cycle-counted delays in a .S file Count a loop in CPU cycles from the data sheet and measure it with Timer 1, then write the delay as a function in its own assembly file and call it from C++. | 45 min

- Run it: 202 cycles
- Count it yourself
- Write it in a .S file
- Blink with your function
- When counting cycles lies

Reading a halt in the debugger Ten readings of 30 that average 4: stop the Uno on a breakpoint, watch a variable climb, step one instruction and read the carry flag in SREG, then fix the bug the halt showed you. | 50 min

- Run it: a wrong answer, no error
- Stop on a line
- Watch it climb, and fall
- Read the carry flag
- Fix it
- The lamp agrees

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Reading a halt in the debugger" 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: "The lamp agrees".

Chapter 4. About 50 min

## Speak a protocol

A UART frame drawn by hand on a plain pin.

Lesson | Time | What students do

Bit-banging a protocol Draw UART frames by hand on a plain pin with counted delays, let the Mega's real USART receiver judge them, read them on the logic analyzer, and break the baud rate on purpose. | 50 min

- Run it: a UART with no UART
- Draw a frame
- The hardware agrees
- See it on the analyzer
- Break the baud rate
- Say something else

### Materials

- Arduino Mega 2560 R3
- Logic analyzer, four channels

### Check for understanding

Each student finishes "Bit-banging a protocol" 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: "Say something else".

Your class

## Teach this unit as a class

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