Advertisement
androidgeek18

Volume Calculator

Mar 28th, 2024 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | Source Code | 0 0
  1. volatile long pulse; //pulse variable
  2. float volume; //volume variable
  3. const float calibrationFactor = 0.307; //calibration formula
  4.  
  5. in your setup()
  6.  
  7. attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_PIN), increase, RISING); // Attach interrupt to the flow sensor pin
  8.  
  9. void increase() {
  10. pulse++;
  11. } //function for rising pulse count
  12.  
  13. // Function to recalculate volume based on pulse count
  14. void updateVolume()
  15. {
  16. const float calibrationFactor = 0.307;
  17. volume = calibrationFactor * pulse;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement