/********* 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: Relay Control
	- Source Code NOT compiled for: Arduino Uno
	- Source Code created on: 2024-06-27 03:23:23

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Automate plant watering using a relay module. */
	/* Control two relay channels connected to digital */
	/* pins D2 and D3 to manage water pumps. Ensure the */
	/* system updates output states continuously in the */
	/* loop function. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include <Relay.h>  //https://github.com/rafaelnsantos/Relay

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void updateOutputs(void);

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t relay_RelayModule_Signal_PIN_D2 = 2;
const uint8_t relay_RelayModule_Signal_PIN_D3 = 3;

/***** DEFINITION OF OUTPUT RAW VARIABLES *****/
/***** used to store raw data *****/
bool relay_RelayModule_Signal_PIN_D2_rawData = 0;
bool relay_RelayModule_Signal_PIN_D3_rawData = 0;

/***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
/***** used to store data after characteristic curve transformation *****/
float relay_RelayModule_Signal_PIN_D2_phyData = 0.0;
float relay_RelayModule_Signal_PIN_D3_phyData = 0.0;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
Relay relay1(relay_RelayModule_Signal_PIN_D2, true); // Initialize relay on pin 2, Normally Open
Relay relay2(relay_RelayModule_Signal_PIN_D3, true); // Initialize relay on pin 3, Normally Open

void setup(void)
{
    // put your setup code here, to run once:

    relay1.begin(); // Initialize the pin for relay1
    relay2.begin(); // Initialize the pin for relay2
}

void loop(void)
{
    // put your main code here, to run repeatedly:

    updateOutputs(); // Refresh output data
}

void updateOutputs()
{
    // Update the state of relay1
    if (relay_RelayModule_Signal_PIN_D2_rawData)
        relay1.turnOn();
    else
        relay1.turnOff();

    // Update the state of relay2
    if (relay_RelayModule_Signal_PIN_D3_rawData)
        relay2.turnOn();
    else
        relay2.turnOff();
}

/* END CODE */