pleasedontcode

Blinking LED rev_01

Oct 13th, 2025
198
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: Blinking LED
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-10-13 21:02:09
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* blink led every 2 seconds */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. // Global state for LED blinking
  33. const int LED_PIN = 13; // UNO built-in LED on digital pin 13
  34. bool ledOn = false;     // current LED state
  35. unsigned long previousMillis = 0; // last time LED was toggled
  36. const unsigned long INTERVAL = 1000; // 1 second interval to achieve 2 second blink cycle
  37.  
  38. void setup(void)
  39. {
  40.     // put your setup code here, to run once:
  41.     pinMode(LED_PIN, OUTPUT);
  42.     digitalWrite(LED_PIN, LOW); // ensure LED starts in the OFF state
  43.     previousMillis = millis();
  44. }
  45.  
  46.  
  47. void loop(void)
  48. {
  49.     // put your main code here, to run repeatedly:
  50.     unsigned long currentMillis = millis();
  51.     if (currentMillis - previousMillis >= INTERVAL)
  52.     {
  53.         previousMillis = currentMillis;
  54.         ledOn = !ledOn;
  55.         digitalWrite(LED_PIN, ledOn ? HIGH : LOW);
  56.     }
  57. }
  58.  
  59. /* END CODE */
  60.  
Advertisement
Add Comment
Please, Sign In to add comment