GY-63_MS5611/libraries/RunningAverage/examples/ra_test/ra_test.ino

45 lines
760 B
Arduino
Raw Normal View History

//
2021-05-26 10:39:03 -04:00
// FILE: runningAverageTest.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.01
// DATE: 2012-12-30
//
// PUPROSE: show working of runningAverage
//
2021-05-26 10:39:03 -04:00
#include "RunningAverage.h"
RunningAverage myRA(10);
int samples = 0;
2021-05-26 10:39:03 -04:00
void setup(void)
{
Serial.begin(115200);
Serial.println("Demo RunningAverage lib");
Serial.print("Version: ");
Serial.println(RUNNINGAVERAGE_LIB_VERSION);
myRA.clear(); // explicitly start clean
}
2021-05-26 10:39:03 -04:00
void loop(void)
{
long rn = random(0, 1000);
myRA.addValue(rn * 0.001);
samples++;
Serial.print(samples);
Serial.print("\t Running Average: ");
Serial.println(myRA.getAverage(), 3);
if (samples == 300)
{
samples = 0;
myRA.clear();
Serial.println();
}
delay(10);
2021-05-26 10:39:03 -04:00
}
// -- END OF FILE --