Created
March 30, 2024 14:44
-
-
Save delasign/e58e0671cab31ab2bf6089b0d9c8ce1e to your computer and use it in GitHub Desktop.
Sample High Pass Filter in 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
float alpha = 0.1; // Filter constant, lower value means more filtering | |
float prevValue = 0.0; // Previous filtered value | |
float filteredValue; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
float rawValue = analogRead(A0); // Read the raw analog input | |
// Apply the high-pass filter | |
filteredValue = rawValue - (prevValue * alpha); | |
prevValue = rawValue; | |
// Print the filtered value | |
Serial.println(filteredValue); | |
delay(10); // Delay to control the sampling rate | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment