Advertisement
pleasedontcode

Flow Initialization rev_174

Dec 7th, 2023
74
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 Initialization
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-07 15:41:38
  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.  
  26. // Include the library for Flow Sensor
  27. #include <FlowSensor.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  34. const uint8_t sens_YF_B1_OUT_PIN_D2 = 2;
  35.  
  36. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. const uint8_t VERDE_LED_PIN_D11 = 11;
  38. const uint8_t ROSSO_LED_PIN_D12 = 12;
  39.  
  40. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  41. // Create an instance of the FlowSensor class
  42. FlowSensor Sensor(YFB1, sens_YF_B1_OUT_PIN_D2);
  43.  
  44. void count()
  45. {
  46.   Sensor.count();
  47. }
  48.  
  49. void setup(void)
  50. {
  51.   // put your setup code here, to run once:
  52.  
  53.   // Initialize the Flow Sensor
  54.   Sensor.begin(count);
  55.  
  56.   pinMode(VERDE_LED_PIN_D11, OUTPUT);
  57.   pinMode(ROSSO_LED_PIN_D12, OUTPUT);
  58.  
  59.   Serial.begin(9600); // Initialize the serial communication
  60.  
  61. }
  62.  
  63. void loop(void)
  64. {
  65.   // put your main code here, to run repeatedly:
  66.  
  67.   // Read the flow rate from the sensor
  68.   float flowRate = Sensor.getFlowRate_h();
  69.  
  70.   // Print the flow rate on the serial monitor
  71.   Serial.print("Flow Rate: ");
  72.   Serial.print(flowRate);
  73.   Serial.println(" L/minute");
  74.  
  75.   delay(1000); // Wait for 1 second
  76.  
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement