-
-
Save BinarySpoon/b6ba4f74a8c861bb7f8f2f65374fd246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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