Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: ESP32 DevKit V1
- - Source Code created on: 2024-05-28 09:48:47
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Designer home automation system in which the ESP */
- /* 32 is able to control 9 relays with using ESP */
- /* RainMaker application and from also control by */
- /* manual switches. */
- /****** 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 Relaymodule_RelayModule_Signal_PIN_D4 = 4;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D13 = 13;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D14 = 14;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D15 = 15;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D16 = 16;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D17 = 17;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D18 = 18;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D19 = 19;
- const uint8_t Relaymodule_RelayModule_Signal_PIN_D21 = 21;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool Relaymodule_RelayModule_Signal_PIN_D4_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D13_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D14_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D15_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D16_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D17_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D18_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D19_rawData = 0;
- bool Relaymodule_RelayModule_Signal_PIN_D21_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float Relaymodule_RelayModule_Signal_PIN_D4_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D13_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D14_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D15_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D16_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D17_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D18_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D19_phyData = 0.0;
- float Relaymodule_RelayModule_Signal_PIN_D21_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Relay relayD4(Relaymodule_RelayModule_Signal_PIN_D4, true); // Initialize relay on pin 4, Normally Open
- Relay relayD13(Relaymodule_RelayModule_Signal_PIN_D13, true); // Initialize relay on pin 13, Normally Open
- Relay relayD14(Relaymodule_RelayModule_Signal_PIN_D14, true); // Initialize relay on pin 14, Normally Open
- Relay relayD15(Relaymodule_RelayModule_Signal_PIN_D15, true); // Initialize relay on pin 15, Normally Open
- Relay relayD16(Relaymodule_RelayModule_Signal_PIN_D16, true); // Initialize relay on pin 16, Normally Open
- Relay relayD17(Relaymodule_RelayModule_Signal_PIN_D17, true); // Initialize relay on pin 17, Normally Open
- Relay relayD18(Relaymodule_RelayModule_Signal_PIN_D18, true); // Initialize relay on pin 18, Normally Open
- Relay relayD19(Relaymodule_RelayModule_Signal_PIN_D19, true); // Initialize relay on pin 19, Normally Open
- Relay relayD21(Relaymodule_RelayModule_Signal_PIN_D21, true); // Initialize relay on pin 21, Normally Open
- void setup(void)
- {
- // put your setup code here, to run once:
- relayD4.begin(); // Initialize the relay on pin 4
- relayD13.begin(); // Initialize the relay on pin 13
- relayD14.begin(); // Initialize the relay on pin 14
- relayD15.begin(); // Initialize the relay on pin 15
- relayD16.begin(); // Initialize the relay on pin 16
- relayD17.begin(); // Initialize the relay on pin 17
- relayD18.begin(); // Initialize the relay on pin 18
- relayD19.begin(); // Initialize the relay on pin 19
- relayD21.begin(); // Initialize the relay on pin 21
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- // Update the state of each relay based on the raw data
- if (Relaymodule_RelayModule_Signal_PIN_D4_rawData)
- relayD4.turnOn();
- else
- relayD4.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D13_rawData)
- relayD13.turnOn();
- else
- relayD13.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D14_rawData)
- relayD14.turnOn();
- else
- relayD14.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D15_rawData)
- relayD15.turnOn();
- else
- relayD15.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D16_rawData)
- relayD16.turnOn();
- else
- relayD16.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D17_rawData)
- relayD17.turnOn();
- else
- relayD17.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D18_rawData)
- relayD18.turnOn();
- else
- relayD18.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D19_rawData)
- relayD19.turnOn();
- else
- relayD19.turnOff();
- if (Relaymodule_RelayModule_Signal_PIN_D21_rawData)
- relayD21.turnOn();
- else
- relayD21.turnOff();
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement