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

51 lines
882 B
Arduino
Raw Normal View History

//
// FILE: runningAverageMinMaxTest.ino
// AUTHOR: Rob Tillaart
// DATE: 2015-apr-10
// PUPROSE: demo
2021-11-24 04:03:41 -05:00
#include "RunningAverage.h"
RunningAverage myRA(10);
int samples = 0;
2021-11-24 04:03:41 -05:00
void setup(void)
{
Serial.begin(115200);
Serial.println("\nDemo runningAverageMinMaxTest");
Serial.print("Version: ");
Serial.println(RUNNINGAVERAGE_LIB_VERSION);
myRA.clear(); // explicitly start clean
Serial.println("\nCNT\tMIN\tAVG\tMAX");
}
2021-11-24 04:03:41 -05:00
void loop(void)
{
long rn = random(0, 1000);
myRA.addValue(rn * 0.001);
samples++;
Serial.print(samples);
Serial.print("\t");
Serial.print(myRA.getMin(), 3);
Serial.print("\t");
Serial.print(myRA.getAverage(), 3);
Serial.print("\t");
Serial.println(myRA.getMax(), 3);
if (samples == 100)
{
samples = 0;
myRA.clear();
Serial.println("\nCNT\tMIN\tAVG\tMAX");
}
delay(10);
}
2021-11-24 04:03:41 -05:00
// -- END OF FILE --
2021-12-28 04:13:44 -05:00