48 lines
990 B
Arduino
48 lines
990 B
Arduino
// Board: Adafruit Feather M0
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <Adafruit_GFX.h>
|
|
#include "Adafruit_LEDBackpack.h" // "Adafruit LED Backpack Library" v1.5.0
|
|
|
|
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);
|
|
matrix.writeDisplay();
|
|
}
|
|
|
|
void setup() {
|
|
matrix.begin(0x70);
|
|
|
|
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();
|
|
Serial.println();
|
|
Serial.println("================");
|
|
Serial.println("BOOT UP");
|
|
|
|
show(99999);
|
|
|
|
}
|
|
|
|
void loop() {
|
|
;
|
|
}
|