# Adafruit-MCP23008-library

> MCP Client

Arduino library for MCP23008/9 I2C I/O expanders. Enables easy control of digital inputs/outputs via I2C.

## Overview

- **Category:** Developer Tools
- **Language:** C++
- **Stars:** 56
- **Forks:** 48
- **Owner:** adafruit
- **GitHub:** https://github.com/adafruit/Adafruit-MCP23008-library
- **Homepage:** http://www.ladyada.net/wiki/partselector/ic#io_expanders
- **Created:** 2010-09-01T20:21:54+00:00
- **Updated:** 2025-06-09T12:06:58+00:00
- **Source:** https://model-context-protocol.com/clients/adafruit-mcp23008-library

## Setup

## Setup

This library is archived and no longer maintained. Please use the replacement library: [https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library](https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library)

**If you still need to use this library (Adafruit MCP23008 Library):**

**Prerequisites:**

*   Arduino IDE installed
*   Adafruit BusIO library: [https://github.com/adafruit/Adafruit_BusIO](https://github.com/adafruit/Adafruit_BusIO)

**Installation:**

1.  Download the library by clicking "Download Source" in the top right corner of the GitHub page.
2.  Unzip the downloaded archive.
3.  Rename the extracted folder to `Adafruit_MCP23008`.
4.  Move the `Adafruit_MCP23008` folder to your Arduino libraries folder.  (Typically located in your Documents folder under `Arduino/libraries/`).  If the `libraries` folder doesn't exist, create it.
5.  Install the Adafruit BusIO library using the Arduino Library Manager (Sketch -> Include Library -> Manage Libraries...) or by manually downloading and installing it into your Arduino libraries folder.
6.  Restart the Arduino IDE.

**Wiring:**

Connect the MCP23008 to your Arduino as follows:

*   Pin #1 (SCL) of the expander to Analog 5 (I2C clock)
*   Pin #2 (SDA) of the expander to Analog 4 (I2C data)
*   Pins #3, 4 and 5 (A0, A1, A2) of the expander to ground (address selection)
*   Pins #6 (RESET) and 18 (VDD) of the expander to 5V (power and reset disable)
*   Pin #9 (VSS) of the expander to ground (common ground)
*   Pins 10 thru 17 are your input/output pins

**Configuration:**

*   No specific configuration files or environment variables are needed. The library is configured through the Arduino code.

**Datasheet:**

*   Refer to the MCP23008 datasheet for more information: [http://ww1.microchip.com/downloads/en/DeviceDoc/21919b.pdf](http://ww1.microchip.com/downloads/en/DeviceDoc/21919b.pdf)

## Tools

## Available Tools

This library provides basic functionality for controlling the MCP23008 I/O expander chip via I2C.  It currently supports the following features:

*   **Setting Pin Directions:** Configures individual pins as either inputs or outputs.
*   **Inputs and Outputs:** Reads digital input values from pins configured as inputs and sets digital output values on pins configured as outputs.
*   **Pull-up Resistors:** Enables or disables internal pull-up resistors on individual pins.

**Usage Examples:**

While specific code examples are not provided in the README, the library allows you to:

1.  **Set a pin as an output:**  You would use a function call (not explicitly shown, but likely named something like `pinMode()` or `digitalWrite()`) to configure a pin as an output.

2.  **Write a HIGH or LOW value to an output pin:** Similar to the above, you would use a function call (likely `digitalWrite()`) to set the voltage level of an output pin.

3.  **Set a pin as an input:**  Use a function call to configure a pin as an input.

4.  **Read the value of an input pin:** Use a function call (likely `digitalRead()`) to retrieve the digital value (HIGH or LOW) of an input pin.

5.  **Enable/Disable Pull-up Resistors:** Use a function call to enable or disable the internal pull-up resistor on a specific pin. This is useful for input pins that need a defined state when not actively driven.
