Advertisement
pleasedontcode

Scanner rev_33

Oct 29th, 2023
52
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: Scanner
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-29 13:53:19
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* If sensor detects dryness in soil, water motor starts.
  24.    If sensor detects wetness in soil, water motor stops. */
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  31. const uint8_t Soilmoisturesensor_PushButton_PIN_D2 = 2;
  32. const uint8_t Soilmoisturesensor_PushButton_PIN_D3 = 3;
  33.  
  34. // Create EasyButton objects for the soil moisture sensor push buttons
  35. EasyButton drynessButton(Soilmoisturesensor_PushButton_PIN_D2);
  36. EasyButton wetnessButton(Soilmoisturesensor_PushButton_PIN_D3);
  37.  
  38. // Define water motor control pin
  39. const uint8_t WaterMotor_PIN = 4;
  40.  
  41. void setup(void)
  42. {
  43.   // Set the input mode for the pins connected to the soil moisture sensor push buttons
  44.   pinMode(Soilmoisturesensor_PushButton_PIN_D2, INPUT_PULLUP);
  45.   pinMode(Soilmoisturesensor_PushButton_PIN_D3, INPUT_PULLUP);
  46.  
  47.   // Set the output mode for the water motor control pin
  48.   pinMode(WaterMotor_PIN, OUTPUT);
  49.  
  50.   // Initialize the EasyButton objects
  51.   drynessButton.begin();
  52.   wetnessButton.begin();
  53.  
  54.   // Add your setup code here, to run once:
  55. }
  56.  
  57. void loop(void)
  58. {
  59.   // Read the state of the soil moisture sensor push buttons
  60.   drynessButton.read();
  61.   wetnessButton.read();
  62.  
  63.   // Check if the dryness button is pressed
  64.   if (drynessButton.isPressed()) {
  65.     // Start the water motor
  66.     digitalWrite(WaterMotor_PIN, HIGH);
  67.   }
  68.  
  69.   // Check if the wetness button is pressed
  70.   if (wetnessButton.isPressed()) {
  71.     // Stop the water motor
  72.     digitalWrite(WaterMotor_PIN, LOW);
  73.   }
  74.  
  75.   // Add your main code here, to run repeatedly:
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement