#include <runningAvg.h>
#include <timeObj.h>
/*
Running average.
This class was developed as a super simple to use data smoother. You decide, when creating
it, how many data points you would like to smooth your data over. Then each time you add a
data point it returns the running average of the last n points that were added. Simple to
use, easy to understand.
Enjoy!
-jim lee
*/
runningAvg smoother(10); // Our smoother. You can change the number of datapoints it will act on.
bool sawEnd;
timeObj checkTimer(100);
// Standard setup stuff..
void setup(void) {
Serial.begin(57600); // Fire up the serial stuff.
sawEnd = true;
}
// Standard loop stuff..
void loop(void) {
int rawValue;
float ave;
if (checkTimer.ding()) {
rawValue = analogRead(A0);
ave = smoother.addData(rawValue); // Pop this number into our smoother. Out pops the average.
if (!smoother.getDelta()) { // It also will give us delta over the data set.
if (!sawEnd) {
Serial.print("Endpoint : ");
Serial.println(rawValue);
sawEnd = true;
}
} else {
sawEnd = false;
}
checkTimer.start();
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
pot1:GND
pot1:SIG
pot1:VCC