You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://github.com/ArminJo/Arduino-FrequencyDetector/commits/master)

18
+
<br/>
19
+
<br/>
20
+
[](https://stand-with-ukraine.pp.ua)
21
+
22
+
Available as [Arduino library "Arduino-FrequencyDetector"](https://www.arduinolibraries.info/libraries/frequency-detector).
[](https://github.com/ArminJo/Arduino-FrequencyDetector/commits/master)
Detects frequency **from 38 Hz to 9612 Hz** and works even on an ATTiny85 with 1 MHz up to 4806 Hz. The input signal can be plotted to the Arduino Serial Plotter resulting in a **simple Oscilloscope** to test the internal signal.
30
+
#### If you find this library useful, please give it a star.
YouTube video of whistle switch example in action.
15
37
@@ -55,7 +77,7 @@ These macros must be defined in your program **before** the line `#include "Freq
55
77
Modify them by enabling / disabling them, or change the values if applicable.
56
78
57
79
| Name | Default value | Description |
58
-
|-|-|-|
80
+
|-|-:|-|
59
81
|`PRINT_INPUT_SIGNAL_TO_PLOTTER`| disabled | Signal input data is stored and can be printed together with trigger levels using `printInputSignalValuesForArduinoPlotter()` like in the *SimpleFrequencyDetector* example to implement a simple digital oscilloscope using the Arduino 1.x Serial Plotter. |
60
82
61
83
### Arduino Plotter output of SimpleFrequencyDetector example with PRINT_INPUT_SIGNAL_TO_PLOTTER enabled
@@ -164,21 +186,21 @@ Discrete microphone amplifier with LM308
boolgetButtonStateIsActive(); // get private member
294
299
boolreadDebouncedButtonState();
295
300
boolupdateButtonState();
296
301
uint16_tupdateButtonPressDuration(); // Updates the ButtonPressDurationMillis by polling, since this cannot be done by interrupt.
@@ -304,7 +309,6 @@ class EasyButton {
304
309
voidhandleINT01Interrupts(); // internal use only
305
310
306
311
bool LastBounceWasChangeToInactive; // Internal state, reflects actual reading with spikes and bouncing. Negative logic: true / active means button pin is LOW
307
-
volatilebool ButtonStateIsActive; // State at last change. Negative logic: true / active means button pin is LOW. If last press duration < BUTTON_DEBOUNCING_MILLIS it holds wrong value (true instead of false) :-(
308
312
volatilebool ButtonToggleState; // Toggle is on press, not on release - initial value is false
309
313
310
314
/*
@@ -351,6 +355,13 @@ class EasyButton {
351
355
#if defined(USE_BUTTON_1)
352
356
static EasyButton *sPointerToButton1ForISR;
353
357
#endif
358
+
359
+
private:
360
+
/*
361
+
* If last press duration < BUTTON_DEBOUNCING_MILLIS it holds wrong value (true instead of false), therefore it is private.
362
+
* To get current state, use readButtonState().
363
+
*/
364
+
volatilebool ButtonStateIsActive; // State at last change. Negative logic: true / active means button pin is LOW.
Copy file name to clipboardExpand all lines: examples/WhistleSwitch/EasyButtonAtInt01.hpp
+43-14Lines changed: 43 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@
15
15
* #include "EasyButtonAtInt01.hpp"
16
16
* EasyButton Button0AtPin2(true);
17
17
*
18
-
* Copyright (C) 2018-2022 Armin Joachimsmeyer
18
+
* Copyright (C) 2018-2024 Armin Joachimsmeyer
19
19
* armin.joachimsmeyer@gmail.com
20
20
*
21
21
* This file is part of EasyButtonAtInt01 https://github.com/ArminJo/EasyButtonAtInt01.
@@ -28,7 +28,7 @@
28
28
* This program is distributed in the hope that it will be useful,
29
29
* but WITHOUT ANY WARRANTY; without even the implied warranty of
30
30
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
31
-
* See the See the See the GNU General Public License for more details.
31
+
* See the GNU General Public License for more details.
32
32
*
33
33
* You should have received a copy of the GNU General Public License
34
34
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
@@ -42,7 +42,7 @@
42
42
* - USE_BUTTON_1 Enables code for button at INT1 (pin3 on 328P, PA3 on ATtiny167, PCINT0 / PCx for ATtinyX5).
43
43
* - INT1_PIN It overrides the usage of pin at the processors INT1 pin. Thus, it is the pin number of the pin for button 1 to use with Pin Change Interrupts.
44
44
* - NO_INITIALIZE_IN_CONSTRUCTOR Disables the auto initializing in all constructors without the aIsButtonAtINT0 parameter.
45
-
* - BUTTON_IS_ACTIVE_HIGH Enable this if you buttons are active high.
45
+
* - BUTTON_IS_ACTIVE_HIGH Enable this if your buttons are active high.
46
46
* - USE_ATTACH_INTERRUPT This forces use of the arduino function attachInterrupt(). It is required if you get the error "multiple definition of __vector_1".
47
47
* - NO_BUTTON_RELEASE_CALLBACK Disables the code for release callback. This saves 2 bytes RAM and 64 bytes program memory.
48
48
* - BUTTON_DEBOUNCING_MILLIS With this you can adapt to the characteristic of your button. Default is 50.
@@ -73,6 +73,12 @@
73
73
*
74
74
*/
75
75
76
+
#if defined(TRACE)
77
+
#defineLOCAL_TRACE
78
+
#else
79
+
//#define LOCAL_TRACE // This enables trace output only for this file
0 commit comments