Skip to content

Instantly share code, notes, and snippets.

@JoshAshby
Created January 11, 2011 23:23
Show Gist options
  • Save JoshAshby/775374 to your computer and use it in GitHub Desktop.
Save JoshAshby/775374 to your computer and use it in GitHub Desktop.
uint8_t ultrasound_filter(char pin) {
filt = (average>>1);
adc = ADCH;
for (j = 0; j <= 16; j++){
if (ADCH > average + 100)
{
adc = (ADCH>>1) + filt;
}
if (ADCH < average - 100){
adc = (ADCH>>1) + filt;
}
rollAverage[j] = adc;
}
for (j = 0; j <= 16; j++){
average += rollAverage[j];
}
average = average>>4;
return average;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment