Ali
August 8, 2017, 8:51pm
21
Ah! I called the wrong method to read.
mcp2.attachInterrupt(button,change,mcp23s17::InterruptMode::FALLING);
It still doesn’t work as intended though. I cannot get it to trigger at all if i use RISING and while in CHANGE or FALLING button presses do not always toggle D7.
This is also not the correct function to reset the flag.
How about mcp2.digitalRead(button)
?
Ali
August 8, 2017, 9:11pm
23
Sorry! I’m having a copy paste hell day!
mcp2.digitalRead(button);
is the one i used.
Try this
void handler(){
uint8_t pin = mcp2.getLastInterruptPin();
uint8_t val = mcp2.getLastInterruptPinValue();
digitalWrite(D7, !digitalRead(D7));
while(mcp2.digitalRead(pin) == val); // wait till interrupt condition goes away
}
BTW, why are you setting up two ISRs handler()
and change()
? What’s happening in change()
?
Ali
August 8, 2017, 9:47pm
25
Looks like i am using a different Library. This one does not even have member functions you listed.
Yup, there are multiple MCS23… libraries, you may try others if one doesn’t give you the results you want.