Created
August 7, 2012 01:36
-
-
Save arjo129/3280529 to your computer and use it in GitHub Desktop.
High pass and low pass filters in c specifically for the Arduino
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
// 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