Created
May 20, 2020 00:38
-
-
Save sixstringsg/4f061b8ba11390c7d8e132e234cef25f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* FreqMeasureMulti - Example with serial output | |
* http://www.pjrc.com/teensy/td_libs_FreqMeasure.html | |
* | |
* This example code is in the public domain. | |
* | |
* I connected PIN 4 to PIN 6, PIN 4 to PIN 10 and PIN 3 to PIN 9 | |
* Results for Serial Output "n, 1463.99, 50.0000000000, 341520.84" | |
* | |
* Uncomment line 95 to see last value change | |
* | |
* There is some jitter in the 50 Hz signal which may be interupts | |
* but more likely just floating point precision | |
*/ | |
#include <FreqMeasureMulti.h> | |
// Measure 3 frequencies at the same time! :-) | |
FreqMeasureMulti freq1; | |
float engineRPM; | |
void setup() { | |
Serial.begin(57600); | |
while (!Serial) ; // wait for Arduino Serial Monitor | |
delay(10); | |
Serial.println("FreqMeasureMulti Begin"); | |
delay(10); | |
freq1.begin(9); | |
} | |
void loop () { | |
float raw = 0; | |
engineRPM = 0; | |
raw = freq1.read(); | |
engineRPM = freq1.countToFrequency(raw) * 14.28; | |
Serial.print("Engine RPM: "); | |
Serial.println(engineRPM); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment