Source: https://mokxi.com/teachers/plans/binary-hex-and-bits
Updated: 2026-11-19

Lesson plan

# Binary, hex and bits lesson plan

What a number really is, one bit a lamp: counting in binary, hex, AND OR XOR, shifts and masks, signed numbers and the lies floats tell. Ends with a binary clock you learn to read.

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

- Count in binary on ten lamps, then write it short in hex.
- AND, OR and XOR, then shifts and masks.
- Two's complement, then the float format and its lies.
- A binary clock packed into ten lamps, and a quiz to read it.

### Materials for the whole unit

- Arduino Uno R3
- Full-size breadboard
- LED bar graph, 10 segments
- Potentiometer
- Resistor x 10

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

## Base two

Count in binary on ten lamps, then write it short in hex.

Lesson | Time | What students do

Counting in binary Ten lamps, ten bits: a counter you can watch, what each lamp is worth, reading a binary number by hand, the biggest number ten bits hold, rolling over, and the knob as a 10-bit number. | 40 min

- Run it: a counter on ten lamps
- What each lamp is worth
- Read one by hand
- The biggest number ten lamps hold
- Roll it over
- The knob is a 10-bit number

Hex shorthand One hex digit is exactly four bits: the sixteen digits, printing with %X, a hex parser written by hand that lights what you type, and making it take lower case too. | 40 min

- Run it: 0x2A
- Four bits a digit
- Type a hex number
- Light only the leftmost lamp
- Take lower case too
- Quick check: predict, then type

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED bar graph, 10 segments
- Potentiometer
- Resistor x 10

### Check for understanding

Each student finishes "Hex shorthand" 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: "Quick check: predict, then type".

Chapter 2. About 1 h 20 min

## Bit tricks

AND, OR and XOR, then shifts and masks.

Lesson | Time | What students do

AND OR XOR Logic on every bit at once: AND keeps the bits a mask allows, OR forces bits on, XOR flips them, all tried on the knob, plus the XOR trick behind a cipher. | 40 min

- Run it: AND
- OR, XOR and NOT
- AND keeps what the mask allows
- OR forces bits on
- XOR flips them
- Quick check: XOR twice

Shifts and masks Shifting left and right to multiply and divide by two, the four one-bit moves every firmware engineer knows (set, clear, toggle, test), pulling a field out of a number, and a scanner eye. | 40 min

- Run it: 1 << 3
- Shift right divides
- Set, clear, toggle, test
- Pull a field out
- A scanner eye
- Make the eye wider

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED bar graph, 10 segments
- Potentiometer
- Resistor x 10

### Check for understanding

Each student finishes "Shifts and masks" 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: "Make the eye wider".

Chapter 3. About 1 h 20 min

## When bits mean numbers

Two's complement, then the float format and its lies.

Lesson | Time | What students do

Signed numbers How eight bits hold -128 to 127: two's complement, flip and add one, the edges of an int8_t, one byte read two ways from the knob, and a submarine dive that does not fit. | 40 min

- Run it: -1 is all ones
- Flip and add one
- Off the edge
- One byte, two meanings
- A dive that does not fit
- Quick check: predict, then read

Floats and their lies A float is 32 bits of sign, exponent and fraction: ten dimes that miss a dollar by one bit, the bits of 1.0, a number too big to add one to, the knob as a float on the lamps, and comparing with a tolerance. | 40 min

- Run it: ten dimes
- Only four bytes
- Inside a float
- Too big to add one
- The knob as a float
- Compare with a tolerance

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED bar graph, 10 segments
- Potentiometer
- Resistor x 10

### Check for understanding

Each student finishes "Floats and their lies" 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: "Compare with a tolerance".

Chapter 4. About 50 min

## Project

A binary clock packed into ten lamps, and a quiz to read it.

Lesson | Time | What students do

Project: a binary clock reader Everything in one build: hours in four bits and minutes in six, packed into ten lamps with a shift and an OR, read back with a mask, a mask bug to find and fix, and a quiz that trains you to read the lamps. Then make it yours. | 50 min

- Run it: 10:28 in binary
- Packing two numbers into one
- The bug at 10:32
- Fix the mask
- Quiz: read the lamps
- Read one on your own
- Make it yours

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED bar graph, 10 segments
- Potentiometer
- Resistor x 10

### Check for understanding

Each student finishes "Project: a binary clock reader" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

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

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.
