Advertisement
Guest User

arduino

a guest
May 31st, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. int sensorPin = A0;
  4. double alpha = 0.75;
  5. int period = 500;
  6. double change = 0.0;
  7. double minval = 0.0;
  8. void setup ()
  9. {
  10. Serial.begin (9600);
  11. }
  12. void loop ()
  13. {
  14. static double oldValue = 0;
  15. static double oldChange = 0;
  16.  
  17. int rawValue = analogRead (sensorPin);
  18. double value = alpha * oldValue + (1 - alpha) * rawValue;
  19.  
  20.  
  21. Serial.print (",");
  22. Serial.println (value/10);
  23. oldValue = value;
  24.  
  25. delay (period);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement