Hello friends, I hope you all are doing great. Today, I am going to share the new MCP23017 I/O Expander Library for Proteus Simulation. The MCP23017 gives an Arduino sixteen more pins over the two I2C wires, and unlike the simplest expanders it gives them the features of real microcontroller pins: a direction for every pin, push-pull outputs, built-in pull-ups, inverted inputs, and an interrupt that tells you which pin changed and what the port looked like at that moment. With this library you can run a full Proteus simulation of the MCP23017 board and watch all twenty-two of its registers at work.
MCP23017 I/O Expander Library for Proteus
Latest version: V1.0 (December 2026, this tutorial)
Related parts: PCF8574 I/O Expander · 5mm LED · DIP Switch
Helping Tools
- Serial Monitor Advance: a serial terminal window for the UART of your board
- Serial Monitor Expert: the serial monitor with extra debugging tools
- LCD Library for Proteus V3.0: 16x2, 20x4 and I2C LCDs to show your readings
The demo runs a light back and forth on eight LEDs, reads a DIP switch with the chip's own pull-ups, and uses a loop-back wire so the interrupt-on-change fires by itself every time the light reaches the end of the row.
NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the LCD board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the MCP23017 I/O Expander Library for Proteus Simulation:
What Is the MCP23017 I/O Expander?
A 16-bit I/O port on I2C, organised as two 8-bit ports, A and B. Each port is controlled by a set of registers, the same way a microcontroller's own ports are: one register sets which pins are inputs or outputs, another switches on pull-ups, another drives the outputs, another reads the pins, and five more handle the interrupts. Three address pins give it eight addresses, 0x20 to 0x27, so eight chips - 128 pins - can share one bus.
| MCP23017 | |
|---|---|
| Pins | 16 (GPA0 - GPA7, GPB0 - GPB7) |
| Address | 0x20 - 0x27 (A2 A1 A0) |
| Registers | 22: 11 per port |
| Outputs | push-pull, 25 mA per pin |
| Inputs | 100 k pull-up and polarity per pin |
| Interrupts | INTA, INTB, which pin and the captured port |
| Supply | 1.8 - 5.5 V |
The Registers
With the default IOCON.BANK = 0 the registers of the two ports alternate, so each pair sits side by side: IODIRA at 0x00 and IODIRB at 0x01, GPPUA at 0x0C and GPPUB at 0x0D, GPIOA at 0x12 and GPIOB at 0x13. IODIR is the direction (1 = input, the power-on value), IPOL inverts an input, GPPU switches on the 100 k pull-up, OLAT is the output latch, and GPIO reads the pins (a write to GPIO goes to OLAT). Setting BANK = 1 regroups them by port, A at 0x00 - 0x0A and B at 0x10 - 0x1A; the model supports both maps.
The Register Pointer
Every write starts with the register address, and every following byte goes to the next register: the pointer moves on by itself. So one transaction - the address 0x00 followed by 0x00 and 0xFF - sets port A to outputs and port B to inputs at once. Reads work the same way: set the pointer, then read as many registers as you need. IOCON.SEQOP = 1 stops the pointer for byte-by-byte polling of one register.
Interrupt-on-Change
This is where the MCP23017 really outclasses a simple expander. GPINTEN chooses which pins may interrupt. INTCON chooses how: 0 means on any change, 1 means whenever the pin differs from its DEFVAL bit. When it happens, INTF shows which pin caused it and INTCAP captures the whole port at that instant - so even a short pulse is not lost - and INTA or INTB goes active. Reading INTCAP or GPIO clears it. IOCON adds three options: MIRROR ties INTA and INTB together, ODR makes them open drain so several chips can share a line, and INTPOL makes them active high.
Features of the MCP23017 I/O Expander Library for Proteus Simulation
- A real-looking board: the 25 x 42 mm board at its real size, with the PWR LED while it runs.
- All 22 registers: both BANK maps, the auto-incrementing pointer and SEQOP.
- Real pins: push-pull outputs, inputs with the 100 k pull-ups and IPOL.
- Interrupts: on change or against DEFVAL, INTF and INTCAP, INTA / INTB with MIRROR, ODR and INTPOL, cleared by reading GPIO or INTCAP.
- A pop-up: the 16 pins (direction, level, pull-up, interrupt) and every register of both ports - graphs, an event log and a check page.
- A complete package: about 2.2 MB with the library, our LEDs, resistors and DIP switch, our Arduino UNO V4.0 and the demo, without the source code of the model.
The MCP23017 in Proteus
The device is IOEXPMCP23017TEP in TEPMCP23017.LIB, under Modules > Interface, with the prefix U and the model TEPMCP23017.DLL. Search MCP23017 or expander in Pick Devices. On the left are VCC, GND, SDA, SCL, RST, A0 to A2, INTA and INTB; on the right the sixteen GP pins. One property: ADDRESS, for the address pins you leave open.
Download MCP23017 I/O Expander Library for Proteus Simulation
Click the button below to download MCP23017-IO-Expander-Library-for-Proteus-v1.0.zip (about 2.2 MB, without the source code of the models):
MCP23017 I/O Expander Library for Proteus V1.0- README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
- Proteus Library Files:
TEPMCP23017.LIB,TEPLED5MM.LIB,TEPRESISTOR.LIB,TEPDIP.LIBandArduinoV4TEP.LIB. - Proteus Model Files: the DLLs of the same names and
TEPARDUINO.DLL. - Arduino Code: the demo sketch (Wire only).
- Proteus Simulation: the demo project, its HEX file and copies of the DLLs.
No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.
How to Install MCP23017 I/O Expander Library for Proteus Simulation
- Close Proteus and extract the whole zip file, for example to your Desktop.
- Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
- Copy the files from Proteus Model Files into the MODELS folder.
- Delete
TEPMCP23017.IDXfrom the LIBRARY folder if it is there. - Start Proteus, press P and search for MCP23017.
Proteus Simulation of a Running Light with Interrupts
The demo uses an A3 sheet with our Arduino UNO Library for Proteus V4.0 and the MCP23017 U1 at 0x20 on A4 and A5, with INTB on D2. Port A drives eight red LEDs from our 5mm LED Library for Proteus, each through 220 ohm to ground - the MCP23017 can source current, so the LEDs are wired the "natural" way, unlike on a PCF8574 I/O Expander Library for Proteus. Port B reads a 4-way switch from our DIP Switch Library for Proteus on GPB0 to GPB3, switches 1 and 3 ON, and GPB7 is wired straight back to GPA7. The Arduino's monitor is built in, the same window as our TEP Serial Monitor Advance for Proteus. Open MCP23017-Running-Light-ArduinoUnoV4.pdsprj.
The Sketch
The sketch needs only the Wire library. The set-up shows the auto-incrementing pointer - both directions in one write - then the pull-ups, the inverted inputs and the interrupts on port B:
wr2(IODIRA, 0x00, 0xFF); // IODIRA = 0x00 (outputs), IODIRB = 0xFF (inputs): one write, two registers
wr(GPPUB, 0x0F); // pull-ups on GPB0 - GPB3 (the switches)
wr(IPOLB, 0x0F); // inverted: a switch ON (LOW) reads 1
wr(INTCONB, 0x00); // interrupt on any change
wr(GPINTENB, 0x8F); // on GPB0 - GPB3 and GPB7 (the loop-back)
In the loop, a LOW on D2 means INTB is active. The sketch reads INTFB to see which pin it was and INTCAPB to see the port at that moment - and that read clears the interrupt:
if (digitalRead(PIN_INT) == LOW) { // INTB: read which pin (INTFB) and the port at that moment (INTCAPB - clears it)
const byte f = rd(INTFB), cap = rd(INTCAPB);
MCP23017 Simulation Results
Open the project and press Run. The demo runs 3.2 simulated seconds and took about 1 minute 52 seconds on our PC with the pop-up open and the pictures being taken. Click the board for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.
The Set-Up
The chip powers up the way the datasheet says: all sixteen pins inputs (IODIR 0xFF), no pull-ups, IOCON.BANK = 0. The sketch's set-up takes less than two milliseconds of bus time, and the Event log lists every write with its time: IODIRA = 0x00 at 68.8 ms (port A becomes eight outputs), IODIRB = 0xFF at 68.9 ms, GPPUB = 0x0F at 69.2 ms (the pull-ups on the four switch pins), IPOLB = 0x0F at 69.5 ms (those four read inverted), INTCONB = 0x00 at 69.9 ms (interrupt on any change) and GPINTENB = 0x8F at 70.2 ms (interrupts on GPB0 to GPB3 and on GPB7). The sketch then reads both direction registers back, and the monitor prints "IODIRA 0x0 IODIRB 0xFF".
The Running Light
The running light starts at 94.8 ms with OLATA = 0x01 and moves one LED every 120 ms: 0x02 at 214.0 ms, and so on to GPA7 and back. At 0.73 s the latch held 0x20 (D6 lit), at 0.97 s 0x80 (D8, the end of the row), at 2.29 s 0x10 on the way back and at 3.20 s 0x08. Unlike the PCF8574, the MCP23017's outputs are real push-pull outputs, so each LED runs from its pin through a 220 ohm resistor to ground and a 1 lights it. The pop-up shows the same: port A all OUT, one of them HIGH in green, the rest LOW.
The Switches
Port B reads the DIP switch. Switches 1 and 3 are ON and pull GPB0 and GPB2 to ground, so the pins are 0x0A on the four switch bits - but because IPOLB inverts them, the GPIOB register reads 0x05, a 1 for every switch that is ON. The sketch needs no pull-up resistors and no "~" in its code, and the monitor prints "Switches 1-4: 1010". In the pop-up the switch pins carry the note "pull-up INT": the chip's own 100 k pull-up and the interrupt are both on.
The Loop-Back Interrupt
GPB7 is wired to GPA7, so every time the running light reaches the end of the row, an input changes. The first interrupt comes at 933.9 ms, when GPA7 goes high: INTFB = 0x80 says GPB7 caused it, and the Event log notes the pins captured at that moment, 0x8A. The sketch reads INTCAPB through the same polarity, so it gets 0x85, and that read also releases INTB. 120 ms later, at 1.054 s, the light moves on, GPB7 goes low and a second interrupt follows (captured 0x0A, read 0x05). The light needs 1.68 s for a full sweep, so the pair comes back at 2.614 s and 2.734 s - four interrupts in the run, all from GPB7, none from the switches nobody touched.
The Graphs, the Event Log and the Check Page
The Graphs page plots both ports and both interrupt lines: port A stepping through the light, port B steady with a spike each time GPB7 follows GPA7, and INTB pulsing. The Event log lists the set-up writes and the first interrupts with the pin that caused them. The Check page sums up the run: Supply green at 5.00 V with the chip at 0x20; port A IODIR 0x00, OLAT 0x08, pins 0x08; port B IODIR 0xFF, GPPU 0x0F, pins 0x0A; interrupts A 0 and B 4 with GPINTENB 0x8F and IOCON 0x00; and the host line with 49 writes, 18 reads, 0 NACKs and 0 resets.
The Arduino's built-in serial monitor shows the set-up read back, the switches and then one line for each interrupt: "INT #1: INTFB 0x80 (GPB7, the loop-back) INTCAPB 0x85", then #2 with 0x5, #3 with 0x85 and #4 with 0x5.
Why INTCAP Matters
An interrupt is only useful if you can tell what happened. By the time the Arduino has noticed INTB and started its I2C read, a short pulse may already be over - reading GPIO would show nothing unusual. INTCAP solves that: the chip freezes the port at the moment of the interrupt, and keeps it until you read it. In the demo the loop-back pulse on GPB7 lasts 120 ms, so either register would do, but a button bounce or a sensor's alarm pulse can be much shorter. INTF adds the other half: which pin it was, without comparing values yourself.
MCP23017 or PCF8574?
Choose the PCF8574 I/O Expander Library for Proteus when you need a few pins and the simplest code: one byte out, one byte in. Choose the MCP23017 when you need sixteen pins, outputs that can source current, pull-ups you can switch, or interrupts that report the pin. The price is a little more set-up - a handful of register writes - and the reward is pins that behave like a microcontroller's own.
Try It Yourself
- Click the DIP switches while it runs: each change raises INTB (GPINTENB includes them) and the sketch reports the switch.
- Set INTCONB to 0x80 and DEFVALB to 0x00: GPB7 interrupts only while it is high, not on both edges.
- Write IOCON = 0x40 (MIRROR) and wire INTA instead of INTB: one line for both ports.
- Remove the GPPU write: the open switch inputs float, and the readings are no longer reliable.
- Set IOCON.BANK = 1 and watch the register addresses move - then change the sketch's addresses to match.
Ideas to Extend the Demo
- A 4x4 keypad on port B with the pull-ups and an interrupt per key press.
- A 7-segment display on port A and buttons on port B.
- Two or more MCP23017 at 0x20 and 0x21 for 32 pins.
Your Own Sketches
The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.
Things to Know Before Using a Real MCP23017
- Power-on: all pins inputs, no pull-ups - write IODIR before using a pin as an output.
- RESET: must be high; many boards pull it up, a bare chip needs it tied to VCC.
- Current: 25 mA per pin, about 150 mA for the whole chip.
- Interrupts: always read INTCAP or GPIO in the handler, or the line stays active.
- Addresses: A0 - A2 must be tied - on a bare chip, floating address pins give random addresses.
Troubleshooting
- An output stays low: IODIR still has a 1 for that pin - write IODIR first.
- A switch reads a random value: the pull-up is off - write GPPU.
- Writes land in the wrong register: IOCON.BANK was changed and the addresses moved.
- INTA / INTB stays active: the sketch never reads GPIO or INTCAP of that port.
- The part is not simulated:
TEPMCP23017.DLLis missing from MODELS and from the project folder.
Limitations of the Simulation
- The registers, both BANK maps, the pointer, the pins, the pull-ups and the interrupts follow the MCP23017 datasheet; the board is our own drawing.
- Our own figures: an output is a strong high or low, a pull-up a weak high.
- Not modelled: the pin current limits, the slew-rate control (DISSLW), the HAEN bit (it belongs to the SPI version), the 1.7 MHz bus mode.
- Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the chip's maker.
- Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.
So, that was all about the MCP23017 I/O Expander Library for Proteus Simulation. I hope it gives your projects all the pins they need - with interrupts that tell the whole story. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!