Source: https://mokxi.com/teachers/plans/more-pins-expanders
Updated: 2026-11-19

Lesson plan

# 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.

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

- 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.

Chapter 1. About 1 h 40 min

## Shift registers

Eight outputs and eight inputs on three pins each.

Lesson | Time | What students do

74HC595: eight outputs on three pins A 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

- Run it: a byte on eight LEDs
- Shift, then latch
- A scanner
- Bit order
- Chaining

74HC165: eight inputs on three pins The 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

- Run it: eight switches
- Load, then shift out
- The shiftIn() trap
- Read first, clock after
- More switches, still three pins

### 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".

Chapter 2. About 2 h 30 min

## On the I2C bus

Expanders, an analog mux and an I2C mux.

Lesson | Time | What students do

I2C expanders: PCF8574 and MCP23017 Extra 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

- Run it: two chips on the bus
- The PCF8574: a byte is the pins
- The MCP23017: a real port
- Your own pattern
- Choosing an expander

CD74HC4067: sixteen analog channels An 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

- Run it: three knobs on one pin
- Pick a channel
- Turn a knob
- An empty channel floats
- Print all sixteen

TCA9548A: same address, one bus Two 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

- Run it: indoor and outdoor
- Scan each channel
- Cold outside
- Two channels at once
- When to use a mux

### 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".

Chapter 3. About 50 min

## Drivers

Sixteen PWM channels that run themselves.

Lesson | Time | What students do

PCA9685: sixteen PWM channels for LEDs Sixteen 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

- Run it: four brightnesses
- On and off counts
- Full brightness
- A breathing wave
- Slow it down

### 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".

Chapter 4. About 1 h

## Boss project

A spaceship control deck with sixty-four buttons on two wires.

Lesson | Time | What students do

Boss: a 64-button control deck A 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

- Run it: the control deck
- Scanning through an expander
- Every key is a system
- Two decks at once
- All stop
- Feedback for every button

### 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".

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.
