PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
|
- /* FreqMeasure - Example with serial output
- * http://www.pjrc.com/teensy/td_libs_FreqMeasure.html
- *
- * This example code is in the public domain.
- */
- #include <FreqMeasure.h>
-
- void setup() {
- Serial.begin(57600);
- FreqMeasure.begin();
- }
-
- double sum=0;
- int count=0;
-
- void loop() {
- if (FreqMeasure.available()) {
- // average several reading together
- sum = sum + FreqMeasure.read();
- count = count + 1;
- if (count > 30) {
- float frequency = FreqMeasure.countToFrequency(sum / count);
- Serial.println(frequency);
- sum = 0;
- count = 0;
- }
- }
- }
|