Comments (2)
Hello try this code for interrupt with esp32 .
#include <Wire.h>
#include <Adafruit_MCP23017.h>
Adafruit_MCP23017 mcp;
byte ledPin = 8;
byte arduinoIntPin = 25;
volatile boolean awakenByInterrupt = false;
static uint16_t ledState = 0;
byte mcpPinA = 7;
void setup() {
Serial.begin(9600);
Serial.println("MCP23007 Interrupt Test");
pinMode(arduinoIntPin, INPUT);
mcp.begin(); // use default address 0
mcp.pinMode(ledPin, OUTPUT);
mcp.pinMode(mcpPinA, INPUT);
mcp.pullUp(mcpPinA, HIGH); // turn on a 100K pullup internally
mcp.setupInterrupts(true, false, LOW);
mcp.setupInterruptPin(mcpPinA, FALLING);
mcp.readGPIOAB();
attachInterrupt(digitalPinToInterrupt(arduinoIntPin), intCallBack, FALLING);
}
// The int handler will just signal that the int has happen
// we will do the work from the main loop.
void intCallBack() {
awakenByInterrupt = true;
}
void handleInterrupt() {
uint8_t pin = mcp.getLastInterruptPin();
uint8_t val = mcp.getLastInterruptPinValue();
if ( pin == mcpPinA && val == 0) { // Test for release - pin pulled high
if ( ledState ) {
mcp.digitalWrite(ledPin, LOW);
} else {
mcp.digitalWrite(ledPin, HIGH);
}
ledState = ! ledState;
}
while ( !mcp.digitalRead(mcpPinA));
// and clean queued INT signal
cleanInterrupts();
}
void cleanInterrupts() {
delay(50);
mcp.readGPIOAB();
awakenByInterrupt = false;
}
void loop() {
if (awakenByInterrupt) handleInterrupt();
}
from adafruit-mcp23017-arduino-library.
Closing. Seems like above example resolved this.
from adafruit-mcp23017-arduino-library.
Related Issues (20)
- Not working using new Arduino Nano ESP32 development board HOT 4
- ESP32 LAN8720 MCP23017 cant compile with Asyncwebsockets
- Old Version of Lib in PlatformIO HOT 4
- mcp23S17 software addressing support HOT 7
- Missing migration guide/instructions to the major 2.x release HOT 2
- Does not work with more than 2 MCP23017 on the same bus. HOT 11
- Communicating with chips with I2C addresses does not work HOT 3
- setupInterrupts issue with 8 MCP23017 HOT 1
- MCP23017 not working with Raspberry Pi Pico HOT 4
- Version 2.0.2 does not compile with Teensy 4.1 HOT 4
- Please add support for reading a “bank” all at once HOT 2
- Increased program memory occupancy HOT 1
- Provide access to INTCAP HOT 7
- How to define the Hardware Adress with I²C? HOT 1
- Please include an example for using multiple mcp chips HOT 3
- Adafruit_MCP23XXX::digitalWrite should read/modify/write the output register, not the input register HOT 24
- Support boards with only SPI or Wire (I2C)
- Bulk set gpio direction support HOT 1
- HELP - Multiple MCP23S17 HOT 2
- GPIO7 bug hacking HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit-mcp23017-arduino-library.