Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile long pulse; //pulse variable
- float volume; //volume variable
- const float calibrationFactor = 0.307; //calibration formula
- in your setup()
- attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_PIN), increase, RISING); // Attach interrupt to the flow sensor pin
- void increase() {
- pulse++;
- } //function for rising pulse count
- // Function to recalculate volume based on pulse count
- void updateVolume()
- {
- const float calibrationFactor = 0.307;
- volume = calibrationFactor * pulse;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement