#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
}