Advertisement
pleasedontcode

FirstSignUp rev_01

Oct 21st, 2023
104
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: FirstSignUp
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-21 08:16:57
  15.     - Source Code generated by: khan
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20.  
  21. /****** SYSTEM REQUIREMENT 1 *****/
  22. /* Turn Light Automatically when it goes off */
  23.  
  24. /****** FUNCTION PROTOTYPES *****/
  25. void setup(void);
  26. void loop(void);
  27. void turnOnLight(void);
  28. void turnOffLight(void);
  29.  
  30. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  31. const uint8_t myled_LED_PIN_D2 = 2;
  32. const uint8_t myled_LED_PIN_D3 = 3;
  33.  
  34. bool isLightOn = false;
  35.  
  36. void setup(void)
  37. {
  38.   // Initialize the digital output pins
  39.   pinMode(myled_LED_PIN_D2, OUTPUT);
  40.   pinMode(myled_LED_PIN_D3, OUTPUT);
  41. }
  42.  
  43. void loop(void)
  44. {
  45.   // Check if the light is off
  46.   if (!isLightOn)
  47.   {
  48.     // Turn on the light
  49.     turnOnLight();
  50.     isLightOn = true;
  51.   }
  52.   else
  53.   {
  54.     // Turn off the light
  55.     turnOffLight();
  56.     isLightOn = false;
  57.   }
  58.  
  59.   // Delay for 1 second
  60.   delay(1000);
  61. }
  62.  
  63. void turnOnLight(void)
  64. {
  65.   // Set the digital output pins to HIGH to turn on the light
  66.   digitalWrite(myled_LED_PIN_D2, HIGH);
  67.   digitalWrite(myled_LED_PIN_D3, HIGH);
  68. }
  69.  
  70. void turnOffLight(void)
  71. {
  72.   // Set the digital output pins to LOW to turn off the light
  73.   digitalWrite(myled_LED_PIN_D2, LOW);
  74.   digitalWrite(myled_LED_PIN_D3, LOW);
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement