Skip to content

Instantly share code, notes, and snippets.

@MURPHYENGINEERING
Created November 17, 2021 21:39
Show Gist options
  • Save MURPHYENGINEERING/bb807ca3efd11465aa7b33eb09c0f5da to your computer and use it in GitHub Desktop.
Save MURPHYENGINEERING/bb807ca3efd11465aa7b33eb09c0f5da to your computer and use it in GitHub Desktop.
#include <Arduino.h>
String pin_label[] = {
" 15 (SDA): ",
" 4 (SCL): ",
" 9 (RST): "
};
volatile unsigned int num_interrupts[] = { 0, 0, 0 };
void IRAM_ATTR sda_isr() { num_interrupts[0]++; }
void IRAM_ATTR scl_isr() { num_interrupts[1]++; }
void IRAM_ATTR rst_isr() { num_interrupts[2]++; }
void setup() {
Serial.begin(9600);
}
void loop() {
attachInterrupt(15, sda_isr, CHANGE);
attachInterrupt(4, scl_isr, CHANGE);
attachInterrupt(9, rst_isr, CHANGE);
Serial.println("\nInterrupts:");
for (size_t i = 0; i < 3; ++i) {
Serial.println(pin_label[i] + String(num_interrupts[i]));
}
Serial.flush();
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment