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: Blinking LED
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-10-13 21:02:09
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* blink led every 2 seconds */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // Global state for LED blinking
- const int LED_PIN = 13; // UNO built-in LED on digital pin 13
- bool ledOn = false; // current LED state
- unsigned long previousMillis = 0; // last time LED was toggled
- const unsigned long INTERVAL = 1000; // 1 second interval to achieve 2 second blink cycle
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(LED_PIN, OUTPUT);
- digitalWrite(LED_PIN, LOW); // ensure LED starts in the OFF state
- previousMillis = millis();
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- unsigned long currentMillis = millis();
- if (currentMillis - previousMillis >= INTERVAL)
- {
- previousMillis = currentMillis;
- ledOn = !ledOn;
- digitalWrite(LED_PIN, ledOn ? HIGH : LOW);
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment