Advertisement
pleasedontcode

Flow Control rev_161

Dec 6th, 2023
88
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:30:13
  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. /****** SYSTEM REQUIREMENTS *****/
  28. /****** SYSTEM REQUIREMENT 1 *****/
  29. /* read flow meter and print on serial monitor. */
  30. /****** END SYSTEM REQUIREMENTS *****/
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35. void count();
  36.  
  37. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  38. const uint8_t flowmeter_YF_S401_OUT_PIN_D4 = 4;
  39.  
  40. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  41. const uint8_t VERDE_LED_PIN_D11 = 11;
  42. const uint8_t ROSSO_LED_PIN_D12 = 12;
  43.  
  44. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  45. FlowSensor flowSensor(YFS201, flowmeter_YF_S401_OUT_PIN_D4); // Instantiate FlowSensor class object
  46.  
  47. void count()
  48. {
  49.   flowSensor.count();
  50. }
  51.  
  52. void setup(void)
  53. {
  54.   // put your setup code here, to run once:
  55.   pinMode(flowmeter_YF_S401_OUT_PIN_D4, INPUT);
  56.   pinMode(VERDE_LED_PIN_D11, OUTPUT);
  57.   pinMode(ROSSO_LED_PIN_D12, OUTPUT);
  58.   Serial.begin(9600); // Start serial communication
  59.  
  60.   // Initialize the flow sensor
  61.   flowSensor.begin(count);
  62. }
  63.  
  64. void loop(void)
  65. {
  66.   // put your main code here, to run repeatedly:
  67.   // Read flow meter and print on serial monitor
  68.   float flowRate = flowSensor.getFlowRate_h();
  69.   Serial.print("Flow rate: ");
  70.   Serial.print(flowRate);
  71.   Serial.println(" L/min");
  72.   delay(1000); // Delay for 1 second
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement