PinChangeInterruptHandler
An object-oriented pin-change interrupt handler library for the Arduino
Install / Use
/learn @zeitgeist87/PinChangeInterruptHandlerREADME
PinChangeInterruptHandler
An object-oriented pin-change interrupt handler library for the Arduino. It uses a pure C++ virtual method as a callback. This allows for a clean and object oriented design, which is especially useful for libraries. The code is heavily influenced by the excellent PinChangeInterrupt library of NicoHood.
Usage
The usage is very simple. You just inherit from the class PinChangeInterruptHandler and implement the method handlePCInterrupt().
#include <PinChangeInterruptHandler.h>
// Inherit from PinChangeInterruptHandler
class MyLib : PinChangeInterruptHandler {
byte inputPin;
unsigned long localState1;
unsigned long localState2;
public:
MyLib(byte inputPin) : inputPin(pin) {}
void begin() {
pinMode(inputPin, INPUT);
attachPCInterrupt(digitalPinToPCINT(inputPin));
}
void stop() {
detachPCInterrupt(digitalPinToPCINT(inputPin));
}
// Overwrite handlePCInterrupt() method
virtual void handlePCInterrupt(int8_t interruptNum, bool value) {
// Do something
localState1 = value;
// ...
}
};
Related Skills
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.7kCommit, push, and open a PR
