The Adafruit MPC23017 library is not compatible with Teensy4

Rolfdegen

Well-known member
I want to use an MPC23017 on the Wire1 port of Teensy4.1.
The library only works with Wire0. How can I set the MPC23017 on Wire1?
The I2C speed cannot be set to 400 kHz!
Thanks for help. Rolf
 
I solved my problem as follows..

C:
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_MCP23X17.h>

Adafruit_MCP23X17 mcp0;     // 1st MCP chip, set as 15 inputs (Encoders)
Adafruit_MCP23X17 mcp1;     // 2nd MCP chip, set as 15 inputs (Keys)

void setup()
{
    // init IO Expander
    mcp0.begin_I2C(0x21, &Wire1); // Addr 0x20-0x27
    mcp1.begin_I2C(0x22, &Wire1);

    // init Wire1 for Encoders and Keys
    Wire1.begin();
    Wire1.setClock(400000UL); // I2C speed 400KHz
  
  
  
}
 
Back
Top