Advertisement
pleasedontcode

Scanner rev_32

Oct 27th, 2023
110
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-27 16:19:21
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. // Define the input pins for the soil moisture sensor and water motor
  23. const uint8_t soilMoistureSensorPin = 2;
  24. const uint8_t waterMotorPin = 3;
  25.  
  26. // Create an instance of the EasyButton library for the soil moisture sensor
  27. EasyButton soilMoistureSensorButton(soilMoistureSensorPin);
  28.  
  29. void setup() {
  30.   // Set the water motor pin as an output
  31.   pinMode(waterMotorPin, OUTPUT);
  32.  
  33.   // Initialize the soil moisture sensor button
  34.   soilMoistureSensorButton.begin();
  35. }
  36.  
  37. void loop() {
  38.   // Read the state of the soil moisture sensor button
  39.   soilMoistureSensorButton.read();
  40.  
  41.   // Check if the soil moisture sensor button is pressed
  42.   if (soilMoistureSensorButton.isPressed()) {
  43.     // If the soil is dry, start the water motor
  44.     digitalWrite(waterMotorPin, HIGH);
  45.   } else {
  46.     // If the soil is wet, stop the water motor
  47.     digitalWrite(waterMotorPin, LOW);
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement