-
-
Save maxhawkins/ee80daf80eaa404bedd9 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
#include <FreqCounter.h> | |
void setup() { | |
Serial.begin(9600); | |
} | |
unsigned long frq; | |
void loop() { | |
// Initialize the frequency counter on pin 5 | |
// Read from counter every 250ms to see how many pulses there are from the fan | |
FreqCounter::start(250); | |
// Idle until the 250ms have elapsed | |
while (FreqCounter::f_ready == 0) | |
// Convert frequency into unsigned long for serial transport | |
frq = FreqCounter::f_freq; | |
// Since our sensor values are less than 256, we send only the first 8 bits | |
frq = frq & 0xff; | |
// Send first 8 bits of frequency reading as byte over serial | |
Serial.print(frq, BYTE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment