Using the custom I2C pins for Adafruit_MCP23017.h

imanpakii
Posts: 3
Joined: Fri Jan 29, 2021 2:42 am

Using the custom I2C pins for Adafruit_MCP23017.h

Postby imanpakii » Fri Jan 29, 2021 5:13 am

Hello,

I'm using MCP23017 connected to the ESP32. I want to know how to use the Adafruit_MCP23017.h to custom pins.
I'm googling to find how to use the Adafruit_MCP23017.h for custom I2C pins, but I couldn't find any result.
I wrote the codes below myself, but it does not work.

Any help would be appreciated.

Code: Select all

#define IO_SCL 4
#define IO_SDA 16

Adafruit_MCP23017 IO_Expander_Class;

TwoWire I2CBME = TwoWire(0);
void setup()
{
Serial.begin(115200);
I2CBME.begin(IO_SDA ,IO_SCL,40000); // wake up I2C bus
///IO_Expander_Init();
IO_Expander_Class.begin(0x27,&I2CBME);
IO_Expander_Class.pinMode(4, OUTPUT);
IO_Expander_Class.digitalWrite(4, HIGH);
}
void loop{
Serial.print("LITE2 OFF");
Serial.print("\n");
IO_Expander_Class.digitalWrite(4, HIGH);

delay(1000);

Serial.print("LITE2 OFF");
Serial.print("\n");

IO_Expander_Class.digitalWrite(4, LOW);
delay(1000);
}

ESP_Sprite
Posts: 9594
Joined: Thu Nov 26, 2015 4:08 am

Re: Using the custom I2C pins for Adafruit_MCP23017.h

Postby ESP_Sprite » Fri Jan 29, 2021 6:36 am

Moved to Arduino subforum.

Who is online

Users browsing this forum: No registered users and 40 guests