Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- int sensorPin = A0;
- double alpha = 0.75;
- int period = 500;
- double change = 0.0;
- double minval = 0.0;
- void setup ()
- {
- Serial.begin (9600);
- }
- void loop ()
- {
- static double oldValue = 0;
- static double oldChange = 0;
- int rawValue = analogRead (sensorPin);
- double value = alpha * oldValue + (1 - alpha) * rawValue;
- Serial.print (",");
- Serial.println (value/10);
- oldValue = value;
- delay (period);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement