1 // sketch_13_02_simple_smoothing
2 const int samplePin = A1;
3 const float alpha = 0.9;
12 static float smoothedValue = 0.0;
13 float newReading = (float)analogRead(samplePin);
14 smoothedValue = (alpha * smoothedValue) + ((1 - alpha) * newReading);
15 Serial.print(newReading); Serial.print(",");
16 Serial.println(smoothedValue);