Using the 8 Channel Solenoid Driver with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit MCP23017 library and running the provided example code.
You'll need a solenoid motor, external DC power supply and a DC jack to terminal block adapter to follow this example.



Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the breakout Vcc.
Here is an Adafruit Metro wired up to the breakout with two solenoid motors:
-
Board 5V to breakout Vcc (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Motor 1 positive to breakout + (red wire)
- Motor 1 negative to breakout A0 (black wire)
- Motor 2 positive to breakout + (red wire)
- Motor 2 negative to breakout A4 (black wire)
- DC power supply GND to breakout terminal block GND (black wire)
- DC power supply positive to breakout terminal block V+ (red wire)
Library Installation
You can install the Adafruit_MCP23017 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit MCP23017, and select the select the Adafruit MCP23017 Arduino Library library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!
// SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_MCP23X17.h> #define NOID_1 0 // MCP23XXX pin LED is attached to #define NOID_2 4 // MCP23XXX pin LED is attached to Adafruit_MCP23X17 mcp; void setup() { Serial.begin(115200); while (!Serial); Serial.println("8 Channel Solenoid Driver Demo"); if (!mcp.begin_I2C()) { Serial.println("Couldn't find MCP23017.."); while (1); } mcp.pinMode(NOID_1, OUTPUT); mcp.pinMode(NOID_2, OUTPUT); Serial.println("Found MCP23017, looping..."); } void loop() { Serial.println("Solenoid 1!"); mcp.digitalWrite(NOID_1, HIGH); delay(500); mcp.digitalWrite(NOID_1, LOW); delay(500); Serial.println("Solenoid 2!"); mcp.digitalWrite(NOID_2, HIGH); delay(500); mcp.digitalWrite(NOID_2, LOW); delay(500); Serial.println("Together!"); mcp.digitalWrite(NOID_1, HIGH); mcp.digitalWrite(NOID_2, HIGH); delay(1000); mcp.digitalWrite(NOID_1, LOW); mcp.digitalWrite(NOID_2, LOW); delay(2000); Serial.println("Repeat!"); Serial.println(); delay(500); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the breakout recognized over I2C. Then, in the loop, the solenoid connected to pin A0 on the breakout is toggled, followed by the solenoid connected to pin A4. Both motors are then turned on and turned off together. You'll see your motors move and the corresponding LEDs on the breakout turn on and off.
Page last edited April 15, 2025
Text editor powered by tinymce.