pleasedontcode

Nonblocking Blink rev_06

Oct 6th, 2025
58
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:53:59
  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.     Serial.begin(9600);
  43.     pinMode(LED_PIN, OUTPUT);
  44.     digitalWrite(LED_PIN, LOW);
  45.     Serial.println("ciao");
  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