More pins: expanders, muxes and drivers lesson plan
Run out of pins no more: 74HC595 outputs and 74HC165 inputs, PCF8574 and MCP23017 I2C expanders, a CD74HC4067 analog mux, a TCA9548A for twin addresses, PCA9685 PWM for LEDs, and a 64-button spaceship control deck.
Objectives and materials
By the end, students can
- Eight outputs and eight inputs on three pins each.
- Expanders, an analog mux and an I2C mux.
- Sixteen PWM channels that run themselves.
- A spaceship control deck with sixty-four buttons on two wires.
Materials for the whole unit
- 74HC165 input shift register
- 74HC595 shift register
- 8-resistor network
- 8-way DIP switch
- Arduino Uno R3
- CD74HC4067 analog multiplexer
- Full-size breadboard
- Half breadboard
- I/O expander, MCP23017
- I/O expander, PCF8574 x 4
- I2C multiplexer, TCA9548A
- Keypad, 4x4 x 4
- LED x 8
- OLED display, 128x64 x 2
- Potentiometer x 3
- Pressure, humidity and temperature, BME280 x 2
- Pushbutton
- Resistor x 8
- Servo driver, PCA9685 16-channel
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.
Shift registers
Eight outputs and eight inputs on three pins each.
| Lesson | Time | What students do |
|---|---|---|
| 74HC595: eight outputs on three pinsA shift register drives eight LEDs from three pins: bits clocked in one at a time, a latch that changes all eight at once, bit order, and chaining for more. | 50 min |
|
| 74HC165: eight inputs on three pinsThe 595 the other way around: load eight switches at once, clock them out on one pin, and the shiftIn() bug that loses the top bit on this chip. | 50 min |
|
Materials
- 74HC165 input shift register
- 74HC595 shift register
- 8-resistor network
- 8-way DIP switch
- Arduino Uno R3
- Full-size breadboard
- LED x 8
- Resistor x 8
Check for understanding
Each student finishes "74HC165: eight inputs on three pins" 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: "More switches, still three pins".
On the I2C bus
Expanders, an analog mux and an I2C mux.
| Lesson | Time | What students do |
|---|---|---|
| I2C expanders: PCF8574 and MCP23017Extra pins on two wires: the PCF8574, where a byte written is its eight pins, and the MCP23017, with direction and pull-up registers like a real port. | 50 min |
|
| CD74HC4067: sixteen analog channelsAn analog multiplexer: four address lines pick one of sixteen channels and join it to one analog pin, so three knobs, or sixteen, share A0, and an empty channel floats. | 50 min |
|
| TCA9548A: same address, one busTwo sensors and two screens with the same I2C addresses kept apart by a TCA9548A: scans that see different chips on each channel, and what happens if two channels are on at once. | 50 min |
|
Materials
- Arduino Uno R3
- CD74HC4067 analog multiplexer
- Half breadboard
- I/O expander, MCP23017
- I/O expander, PCF8574
- I2C multiplexer, TCA9548A
- OLED display, 128x64 x 2
- Potentiometer x 3
- Pressure, humidity and temperature, BME280 x 2
- Pushbutton
Check for understanding
Each student finishes "TCA9548A: same address, one bus" 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: "When to use a mux".
Drivers
Sixteen PWM channels that run themselves.
| Lesson | Time | What students do |
|---|---|---|
| PCA9685: sixteen PWM channels for LEDsSixteen 12-bit PWM outputs on I2C: a prescaler for the frequency, on and off counts out of 4096, LEDs at four brightness levels, and a breathing wave that runs on its own. | 50 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- LED x 4
- Resistor x 4
- Servo driver, PCA9685 16-channel
Check for understanding
Each student finishes "PCA9685: sixteen PWM channels for LEDs" 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: "Slow it down".
Boss project
A spaceship control deck with sixty-four buttons on two wires.
| Lesson | Time | What students do |
|---|---|---|
| Boss: a 64-button control deckA spaceship control deck with sixty-four buttons on two wires: four keypads, each scanned row by row through its own PCF8574, and every key a ship system that toggles. | 60 min |
|
Materials
- Arduino Uno R3
- Half breadboard
- I/O expander, PCF8574 x 4
- Keypad, 4x4 x 4
Check for understanding
Each student finishes "Boss: a 64-button control deck" 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: "Feedback for every button".
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.