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.
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.
Base two
Count in binary on ten lamps, then write it short in hex.
| Lesson | Time | What students do |
|---|---|---|
| Counting in binaryTen 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 |
|
| Hex shorthandOne 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 |
|
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".
Bit tricks
AND, OR and XOR, then shifts and masks.
| Lesson | Time | What students do |
|---|---|---|
| AND OR XORLogic 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 |
|
| Shifts and masksShifting 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 |
|
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".
When bits mean numbers
Two's complement, then the float format and its lies.
| Lesson | Time | What students do |
|---|---|---|
| Signed numbersHow 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 |
|
| Floats and their liesA 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 |
|
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".
Project
A binary clock packed into ten lamps, and a quiz to read it.
| Lesson | Time | What students do |
|---|---|---|
| Project: a binary clock readerEverything 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 |
|
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".
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.