/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: Scanner
- Source Code compiled for: Arduino Uno
- Source Code created on: 2023-10-29 13:53:19
- Source Code generated by: AlexWind
********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** SYSTEM REQUIREMENT 1 *****/
/* If sensor detects dryness in soil, water motor starts.
If sensor detects wetness in soil, water motor stops. */
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t Soilmoisturesensor_PushButton_PIN_D2 = 2;
const uint8_t Soilmoisturesensor_PushButton_PIN_D3 = 3;
// Create EasyButton objects for the soil moisture sensor push buttons
EasyButton drynessButton(Soilmoisturesensor_PushButton_PIN_D2);
EasyButton wetnessButton(Soilmoisturesensor_PushButton_PIN_D3);
// Define water motor control pin
const uint8_t WaterMotor_PIN = 4;
void setup(void)
{
// Set the input mode for the pins connected to the soil moisture sensor push buttons
pinMode(Soilmoisturesensor_PushButton_PIN_D2, INPUT_PULLUP);
pinMode(Soilmoisturesensor_PushButton_PIN_D3, INPUT_PULLUP);
// Set the output mode for the water motor control pin
pinMode(WaterMotor_PIN, OUTPUT);
// Initialize the EasyButton objects
drynessButton.begin();
wetnessButton.begin();
// Add your setup code here, to run once:
}
void loop(void)
{
// Read the state of the soil moisture sensor push buttons
drynessButton.read();
wetnessButton.read();
// Check if the dryness button is pressed
if (drynessButton.isPressed()) {
// Start the water motor
digitalWrite(WaterMotor_PIN, HIGH);
}
// Check if the wetness button is pressed
if (wetnessButton.isPressed()) {
// Stop the water motor
digitalWrite(WaterMotor_PIN, LOW);
}
// Add your main code here, to run repeatedly:
}