Skip to content

Instantly share code, notes, and snippets.

@BinarySpoon
Created Nov 12, 2020
Embed
What would you like to do?
// Mesaure Distance -->
int MeasureDist() {
static int measurements[MA]; //Static ints persists even after loop is over //
long mean = 0;
for (int i = 0; i < MA; i++)
{
mean += measurements[i];
}
measurements[MA-1] = DIST_SENS.measureDistanceCm();
for (int i = 0; i < MA; i++)
{
mean += measurements[i];
}
return mean /= MA;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment