Advertisement
pleasedontcode

Flow Measurement rev_163

Dec 6th, 2023
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Flow Measurement
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-07 00:50:24
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* read flow meter and print on serial monitor. */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <FlowSensor.h>
  26.  
  27. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  28. const uint8_t sens_YF_S201_OUT_PIN_D2 = 2;
  29.  
  30. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  31. #define type YFS201
  32. #define pin sens_YF_S201_OUT_PIN_D2
  33.  
  34. FlowSensor Sensor(type, pin);
  35.  
  36. void count()
  37. {
  38.   Sensor.count();
  39. }
  40.  
  41. void setup(void)
  42. {
  43.   // put your setup code here, to run once:
  44.   pinMode(sens_YF_S201_OUT_PIN_D2, INPUT);
  45.  
  46.   Serial.begin(115200);
  47.   Sensor.begin(count);
  48. }
  49.  
  50. void loop(void)
  51. {
  52.   // put your main code here, to run repeatedly:
  53.   Sensor.read();
  54.  
  55.   // Print flow rate and volume to Serial Monitor
  56.   Serial.print("Flow rate (L/minute) : ");
  57.   Serial.println(Sensor.getFlowRate_m());
  58.   Serial.print("Volume (L) : ");
  59.   Serial.println(Sensor.getVolume());
  60.  
  61.   delay(1000);
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement