-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitorHz.ino
31 lines (26 loc) · 816 Bytes
/
monitorHz.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <HzMeter_asukiaaa.hpp>
#define PIN_INTERRUPT_HZ_METER 3
#if digitalPinToInterrupt(PIN_INTERRUPT_HZ_METER) < 0
#error needed to assign interrupt pin for PIN_INTERRUPT_HZ_METER
#endif
HzMeter_asukiaaa::Core hzMeter;
// #define HISTORY_LENGTH 5
// HzMeter_asukiaaa::Core hzMeter(HISTORY_LENGTH);
void setup() {
Serial.begin(115200);
hzMeter.begin();
pinMode(PIN_INTERRUPT_HZ_METER, INPUT_PULLUP);
attachInterrupt(
digitalPinToInterrupt(PIN_INTERRUPT_HZ_METER),
[]() { hzMeter.countUp(); }, RISING);
}
void loop() {
hzMeter.onInterval();
auto countInfo = hzMeter.getInfoBundled();
Serial.print(countInfo.calcHzByFirstAndLast());
Serial.print("Hz from ");
Serial.print(countInfo.measuredFrom);
Serial.print(" to ");
Serial.println(countInfo.measuredTill);
delay(1000);
}