Skip to content

Turn off Interrupt Triggers and Pull Up Resistors on begin() #55

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

Merged
merged 10 commits into from
Feb 9, 2021
10 changes: 10 additions & 0 deletions Adafruit_MCP23017.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,20 @@ void Adafruit_MCP23017::begin(uint8_t addr, TwoWire *theWire) {

_wire->begin();

_wire->setClock(400000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz remove


// set defaults!
// all inputs on port A and B
writeRegister(MCP23017_IODIRA, 0xff);
writeRegister(MCP23017_IODIRB, 0xff);

// Turn off interrupt triggers
writeRegister(MCP23017_GPINTENA, 0x00);
writeRegister(MCP23017_GPINTENB, 0x00);

// Turn off pull up resistors
writeRegister(MCP23017_GPPUA, 0x00);
writeRegister(MCP23017_GPPUB, 0x00);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions examples/interrupt/interrupt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ void cleanInterrupts(){
* and you can wait for interrupts while waiting.
*/
void loop(){
// Clear Previous Interrupts
if (digitalRead(arduinoIntPin) == LOW) {
mcp.digitalRead(0);
mcp.digitalRead(7);
}

// enable interrupts before going to sleep/wait
// And we setup a callback for the arduino INT handler.
Expand Down