pleasedontcode

Millis Blink rev_05

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