16-bit I/O Port Expander MCP23017 (I2C)

The MCP23017 is a 16-bit, general purpose parallel I/O port expander for I2C bus applications.

The 16-bit I/O port functionally consists of two 8-bit ports (PORTA and PORTB). The MCP23017 can be configured to operate in 8-bit or 16-bit modes

We also have the SPI version of this chip here MCP23S17

MCP23017 Features

  • 16-bit remote bidirectional I/O port
    - I/O pins default to input
  • • High-speed I2C™ interface (MCP23017)
    - 100 kHz
    - 400 kHz
    - 1.7MHz
  • Three hardware address pins to allow up to eight devices on the bus
  • Operating Voltage: 1.8V to 5.5V

MCP23017 Pinout

Documents

MCP23017 Datasheet

Example Arduino Code

Here is a simple Arduino 1.0 example sketch to flash an LED connected to any pin on Port B

/*
** MCP23017 16 bit Port Expander
** Example code to flash LED on GPB0
** Created 06 Aug 2012
**
** This example code is in the public domain.
** www.hobbytronics.co.uk
*/

#include <Wire.h>

const byte  mcp_address=0x20;      // I2C Address of MCP23017 Chip
const byte  GPIOA=0x12;            // Register Address of Port A
const byte  GPIOB=0x13;            // Register Address of Port B

void setup()
{
  //Send settings to MCP device
  Wire.begin();              // join i2c bus (address optional for master)

  // IOCON.BANK defaults to 0 which is what we want.
  // So we are using Table 1-4 on page 9 of datasheet
  
  Wire.beginTransmission(mcp_address);
  Wire.write((byte)0x00); // IODIRA register
  Wire.write((byte)0x00); // set all of bank A to outputs
  Wire.write((byte)0x00); // set all of bank B to outputs 
  Wire.endTransmission();
  
}

void loop()
{
  Wire.beginTransmission(mcp_address);
  Wire.write(GPIOB);      // address bank B
  Wire.write((byte)0xFF);  // value to send - all HIGH
  Wire.endTransmission();
  
  delay(500);

  Wire.beginTransmission(mcp_address);
  Wire.write(GPIOB);    // address bank B
  Wire.write((byte)0x00);  // value to send - all LOW
  Wire.endTransmission();
  
  delay(500);
}

Write a review

Please login or register to review

16-bit I/O Port Expander MCP23017 (I2C)

  • Manufacturer: Microchip
  • Product Code: MCP23017
  • Availability:  27
  • £1.44

  • Ex Tax: £1.20

Related Products

PCF8574A I2C Port Expander

PCF8574A I2C Port Expander

PCF8574A I2C Port Expander PCF8574A I2C Port Expander IC chip is an 8-bit input/output (I/O) ..

£1.62 Ex Tax: £1.35

16-bit I/O Port Expander MCP23S17 (SPI)

16-bit I/O Port Expander MCP23S17 (SPI)

16-bit I/O Port Expander MCP23S17 (SPI) The MCP23S17 provides 16-bit, general purpose paralle..

£1.20 Ex Tax: £1.00

Tags: 16-bit, 16bit, I/O, Port, Expander, MCP23017, I2C, parallel, bus, inout, output, bidirectional, 5v, 3.3v, ic, chips, Microchip,