-
-
Save OMikeGray/b13f156c080a100a89e5bbd541d0565e 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
float readPotentiometer(void){ | |
int sum = 0; // Sum of Measurements | |
static int j = 0; | |
valuesToAverage[j] = analogRead(A1); // Place Measurement in Buffer with Previous Values | |
for(int i = 0; i < numMeasure; i++){ | |
sum +=valuesToAverage[i]; // Add Up all Muasurements | |
} | |
if(j < numMeasure-1){j++;} | |
else{j = 0;} | |
return conNum*((sum/numMeasure) - 44); // Divide by number of measurements | |
} // & Convert to Inches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment