pleasedontcode

Nonblocking Blink rev_01

Oct 6th, 2025
55
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: Nonblocking Blink
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-10-06 22:35:53
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* give me example led */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /***** LED example configuration *****/
  34. const uint8_t LED_PIN = 13; // Built-in LED on UNO
  35. unsigned long previousMillis = 0;
  36. const unsigned long interval = 500; // Blink interval in milliseconds
  37. bool ledState = false;
  38.  
  39. void setup(void)
  40. {
  41.     // put your setup code here, to run once:
  42.     pinMode(LED_PIN, OUTPUT);
  43.     digitalWrite(LED_PIN, LOW);
  44.     // LED example initialisation complete
  45. }
  46.  
  47.  
  48. void loop(void)
  49. {
  50.     // put your main code here, to run repeatedly:
  51.     unsigned long currentMillis = millis();
  52.     if (currentMillis - previousMillis >= interval)
  53.     {
  54.         previousMillis = currentMillis;
  55.         ledState = !ledState;
  56.         digitalWrite(LED_PIN, ledState ? HIGH : LOW);
  57.     }
  58. }
  59.  
  60. /* END CODE */
  61.  
Advertisement
Add Comment
Please, Sign In to add comment