#include <runningAvg.h>
#include <blinker.h>
#include <timeObj.h>
#define NUM_READINGS 10 // Readings to average over.
#define OUTPUT_MS 250 // How long (in ms) between output lines.
blinker theLED(6,50,500); // Pin 6, On 50ms, period 500ms
runningAvg theSmoother(NUM_READINGS); // Raw data in, avarage out.
timeObj outputTimer(OUTPUT_MS);
void setup() {
Serial.begin(115200); // Start serial,
theLED.setOnOff(true); // Start the blinker.
}
void loop() {
float avarage;
idle(); // Run the magic..
avarage = theSmoother.addData(analogRead(A0)); // Data in, avarage out.
if (outputTimer.ding()) { // If our time's up..
Serial.print("Average : "); // Output the results.
Serial.println(avarage); //
outputTimer.start(); // Restart the timer.
}
}