From 84e1af1894b09af7d4bdf34ffcf742be606a2ecb Mon Sep 17 00:00:00 2001 From: "Tanner Collin (aider)" Date: Thu, 5 Jun 2025 10:47:21 -0600 Subject: [PATCH] feat: Set up tachometer pulse interrupt and ISR --- tach/tach.ino | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tach/tach.ino b/tach/tach.ino index 3ffbfa1..5057d31 100644 --- a/tach/tach.ino +++ b/tach/tach.ino @@ -7,6 +7,14 @@ Adafruit_7segment matrix = Adafruit_7segment(); +// --- Tachometer variables --- +const int TACH_INTERRUPT_PIN = A0; // Or any other digital pin capable of interrupts +volatile unsigned long pulse_count = 0; + +// --- Interrupt Service Routine (ISR) --- +void count_pulse() { + pulse_count++; +} void show(int num) { matrix.print(num, DEC); @@ -19,6 +27,10 @@ void setup() { Serial.begin(115200); // Serial.setDebugOutput(true); + // --- Setup Tachometer Interrupt --- + pinMode(TACH_INTERRUPT_PIN, INPUT_PULLUP); // Set pin as input with internal pull-up resistor + attachInterrupt(digitalPinToInterrupt(TACH_INTERRUPT_PIN), count_pulse, RISING); + delay(1000); Serial.println();