Skip to content

Instantly share code, notes, and snippets.

@arjo129
Created August 7, 2012 01:36
Show Gist options
  • Save arjo129/3280529 to your computer and use it in GitHub Desktop.
Save arjo129/3280529 to your computer and use it in GitHub Desktop.
High pass and low pass filters in c specifically for the Arduino
// Freq is not the frequency in hertz but the time constant RC
int lowpass(int portinput, int freq, int samplerate, int prev){
int RC = samplerate/(samplerate+freq);
int returnd = RC*portinput+(1-RC)*prev;
return returnd;
}
int highpass(int portinput, int freq, int samplerate, int prevport, int prevproc){
int RC = samplerate/(samplerate+freq);
int returnd = RC*(prevproc+portinput-prevproc);
return returnd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment