Advertisement
pleasedontcode

Flow Control rev_164

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 Control
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-07 00:54:45
  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. #define type YFS201
  28. #define sens_YF_B1_OUT_PIN_D2 2
  29. #define VERDE_LED_PIN_D11 11
  30. #define ROSSO_LED_PIN_D12 12
  31.  
  32. // Instantiate the FlowSensor object
  33. FlowSensor sensor(type, sens_YF_B1_OUT_PIN_D2);
  34.  
  35. void count()
  36. {
  37.   sensor.count();
  38. }
  39.  
  40. void setup() {
  41.   // Set pin modes
  42.   pinMode(sens_YF_B1_OUT_PIN_D2, INPUT);
  43.   pinMode(VERDE_LED_PIN_D11, OUTPUT);
  44.   pinMode(ROSSO_LED_PIN_D12, OUTPUT);
  45.  
  46.   // Initialize the FlowSensor
  47.   sensor.begin(count);
  48.  
  49.   // Set baud rate for serial communication
  50.   Serial.begin(115200);
  51. }
  52.  
  53. void loop() {
  54.   // Read flow meter and print on serial monitor
  55.   int flowRate = sensor.getFlowRate_h();
  56.   Serial.print("Flow rate: ");
  57.   Serial.print(flowRate);
  58.   Serial.println(" L/h");
  59.  
  60.   // Add your code here for additional functionality or control
  61.  
  62.   delay(1000); // Delay for 1 second
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement