-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with MCP23017 library #56
Comments
better to change the function to just test if d == INPUT and write 0 |
I have tested the above solution and I think it would be a clean consitent solution for the library. |
great, please submit a PR! |
Sorry, I'm new to github and have to check out, how to submit an PR. It will take a little bit. |
Please try the newly released 2.0.0 version of the library which should resolve this issue: |
Closing for now. Should be fixed with 2.0.0 release. Tested on a Feather ESP32 with following sketch. #include <Adafruit_MCP23X17.h>
#define IN_PIN 0
Adafruit_MCP23X17 mcp;
void setup() {
Serial.begin(9600);
Serial.println("MCP23xxx Input Test!");
if (!mcp.begin_I2C()) {
Serial.println("Error.");
while (1);
}
mcp.pinMode(IN_PIN, INPUT);
}
void loop() {
Serial.print("Input = "); Serial.println(mcp.digitalRead(IN_PIN ));
delay(500);
} and works as expected. |
The 2.0.0/2.1.0 library still does not work with esp32 devkit v1 for some reason........ caused me quite a bit of headache. But works with my esp32-s2, so I'm happy it at least works on something. Hopefully this comment willl save someone a headache seems to be very picky about what esp32 it works on so try different ones. |
Adafruit MCP23017 library includes
void Adafruit_MCP23017::pinMode(uint8_t p, uint8_t d) { updateRegisterBit(p, (d == INPUT), MCP23017_IODIRA, MCP23017_IODIRB); }
Unfortunately INPUT is in Arduino.h 0, which works correct for lot's of uC's,
but not for ESP32, which comes with its own header file.
There, INPUT is defined as 1, so MCP23017 is not correctly initialized.
The Adafruit header file for MCP23017 should include
#define MCP23017_INPUT 0
so that pinMode can be written as
void Adafruit_MCP23017::pinMode(uint8_t p, uint8_t d) { updateRegisterBit(p, (d == MCP23017_INPUT), MCP23017_IODIRA, MCP23017_IODIRB); }
The text was updated successfully, but these errors were encountered: