pleasedontcode

# LED Blink rev_01

Jan 22nd, 2026
21
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: # LED Blink
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2026-01-22 16:08:55
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Manage a lite LED component on Arduino Uno D2 pin */
  21.     /* to enable basic lighting control with digital */
  22.     /* output functionality for prototyping. */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. // No external libraries required for basic digital output control
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void ledOn(void);
  33. void ledOff(void);
  34. void ledBlink(int blinkCount, int delayMs);
  35.  
  36. /****** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. // LED Pin Variable - Lite LED connected to Arduino Uno D2 pin
  38. const int LED_PIN = 2;  // LED connected to digital pin 2
  39.  
  40. /*
  41.  * setup() - This function runs once when you turn your Arduino on
  42.  * We configure the D2 pin as a digital output for LED control
  43.  */
  44. void setup()
  45. {
  46.   // Set D2 pin to output mode for controlling the lite LED
  47.   pinMode(LED_PIN, OUTPUT);
  48.  
  49.   // Initialize LED to OFF state
  50.   digitalWrite(LED_PIN, LOW);
  51. }
  52.  
  53. /*
  54.  * loop() - This function will start after setup finishes and then repeat
  55.  * Demonstrates basic LED control with blinking pattern
  56.  */
  57. void loop()
  58. {
  59.   // Turn LED on for 1 second
  60.   ledOn();
  61.   delay(1000);
  62.  
  63.   // Turn LED off for 1 second
  64.   ledOff();
  65.   delay(1000);
  66.  
  67.   // Blink the LED 3 times with 300ms interval
  68.   ledBlink(3, 300);
  69.   delay(1000);
  70. }
  71.  
  72. /*
  73.  * ledOn() - Turns on the lite LED on D2 pin
  74.  * Provides digital HIGH output to enable the LED
  75.  */
  76. void ledOn(void)
  77. {
  78.   // Set D2 pin to HIGH to turn on the LED
  79.   digitalWrite(LED_PIN, HIGH);
  80. }
  81.  
  82. /*
  83.  * ledOff() - Turns off the lite LED on D2 pin
  84.  * Provides digital LOW output to disable the LED
  85.  */
  86. void ledOff(void)
  87. {
  88.   // Set D2 pin to LOW to turn off the LED
  89.   digitalWrite(LED_PIN, LOW);
  90. }
  91.  
  92. /*
  93.  * ledBlink() - Blinks the lite LED on D2 pin
  94.  * Parameters:
  95.  *   blinkCount - Number of times to blink the LED
  96.  *   delayMs - Delay in milliseconds between each blink state change
  97.  */
  98. void ledBlink(int blinkCount, int delayMs)
  99. {
  100.   // Perform the blink cycle the specified number of times
  101.   for(int i = 0; i < blinkCount; i++)
  102.   {
  103.     // Turn LED on
  104.     ledOn();
  105.     delay(delayMs);
  106.    
  107.     // Turn LED off
  108.     ledOff();
  109.     delay(delayMs);
  110.   }
  111. }
  112.  
  113. /* END CODE */
  114.  
Advertisement
Add Comment
Please, Sign In to add comment