Advertisement
pleasedontcode

Flow Monitoring rev_173

Dec 7th, 2023
70
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 Monitoring
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-07 15:11:16
  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. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  32. const uint8_t sens_YF_B1_OUT_PIN_D2 = 2;
  33.  
  34. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  35. const uint8_t VERDE_LED_PIN_D11 = 11;
  36. const uint8_t ROSSO_LED_PIN_D12 = 12;
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. #define type YFS201 // Replace with the correct value for 'type'
  40. FlowSensor Sensor(type, sens_YF_B1_OUT_PIN_D2); // Initialized FlowSensor instance
  41.  
  42. void setup(void)
  43. {
  44.   // put your setup code here, to run once:
  45.  
  46.   pinMode(sens_YF_B1_OUT_PIN_D2, INPUT);
  47.   pinMode(VERDE_LED_PIN_D11, OUTPUT);
  48.   pinMode(ROSSO_LED_PIN_D12, OUTPUT);
  49.  
  50.   Serial.begin(9600); // Initializing serial communication
  51. }
  52.  
  53. void loop(void)
  54. {
  55.   // put your main code here, to run repeatedly:
  56.  
  57.   // Read flow rate from the sensor
  58.   float flowRate = Sensor.getFlowRate_h();
  59.  
  60.   // Print flow rate on the serial monitor
  61.   Serial.print("Flow rate (L/minute): ");
  62.   Serial.println(flowRate);
  63.  
  64.   delay(1000); // Delay for 1 second before reading again
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement