pleasedontcode

Relay Controller rev_07

Aug 3rd, 2025
325
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: Relay Controller
  13.     - Source Code compiled for: Arduino Opta WiFi
  14.     - Source Code created on: 2025-08-03 10:08:31
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Toggle relay 1 and its associated LED every 3 */
  21.     /* seconds using the connected relay (pin D0) and LED */
  22.     /* component (pin LED_D0) on the Arduino Opta WiFi */
  23.     /* board. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26.  
  27. /* START CODE */
  28. /****** DEFINITION OF LIBRARIES *****/
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. const int relayPin = D0;      // Pin connected to relay 1
  35. const int ledPin = LED_D0;    // Pin connected to LED associated with relay 1
  36.  
  37. void setup(void)
  38. {
  39.   // Initialize relay and LED pins as outputs
  40.   pinMode(relayPin, OUTPUT);
  41.   pinMode(ledPin, OUTPUT);
  42. }
  43.  
  44. void loop(void)
  45. {
  46.   static bool relayState = LOW; // Keep track of relay and LED state
  47.  
  48.   // Toggle relay and LED state
  49.   relayState = !relayState;
  50.   digitalWrite(relayPin, relayState);
  51.   digitalWrite(ledPin, relayState);
  52.  
  53.   delay(3000); // Wait for 3 seconds
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment