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: 2025-07-15 18:42:53
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Génère un code Arduino pour un ESP32 (ESP- */
- /* WROOM-32) utilisant un module MAX485 pour lire les */
- /* valeurs DMX des canaux 1, 2 et 3, en utilisant la */
- /* bibliothèque DMXSerial compatible avec ESP32. */
- /* Inclut la configuration des broches UART. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Relay.h>
- #include <DMXSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t myRelayModule_RelayModule_Signal_PIN_D4 = 4;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool myRelayModule_RelayModule_Signal_PIN_D4_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float myRelayModule_RelayModule_Signal_PIN_D4_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Relay relayDevice(2, false); // Relay on pin 2, normally closed
- void setup(void)
- {
- // Initialize relay pin
- pinMode(myRelayModule_RelayModule_Signal_PIN_D4, OUTPUT);
- // Initialize DMXSerial on UART1 for MAX485 communication
- DMXSerial.init(1);
- }
- void loop(void)
- {
- // Refresh output data
- updateOutputs();
- // Read DMX channels 1, 2, and 3
- int channel1 = DMXSerial.read(1);
- int channel2 = DMXSerial.read(2);
- int channel3 = DMXSerial.read(3);
- // Map DMX channel 1 to relay raw data (HIGH if value > 127, else LOW)
- myRelayModule_RelayModule_Signal_PIN_D4_rawData = (channel1 > 127) ? HIGH : LOW;
- }
- void updateOutputs()
- {
- // Write relay state to the output pin
- digitalWrite(myRelayModule_RelayModule_Signal_PIN_D4, myRelayModule_RelayModule_Signal_PIN_D4_rawData);
- }
Advertisement
Add Comment
Please, Sign In to add comment