Last active
January 6, 2025 18:29
-
-
Save StuffAndyMakes/570a1875833783f9f66d5ea7fc7cfc3e to your computer and use it in GitHub Desktop.
millis() Blink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#define PIN_LED 13 | |
#define LED_STATE_SWITCH_INTERVAL 500 // milliseconds between LED state change | |
unsigned long ledNextStateFlip = 0; | |
bool ledIsOn = false; | |
void setup(void) { | |
pinMode(PIN_LED, OUTPUT); | |
digitalWrite(PIN_LED, LOW); | |
} | |
void loop(void) { | |
if (millis() > ledNextStateFlip) { | |
ledNextStateFlip = millis() + LED_STATE_SWITCH_INTERVAL; | |
ledIsOn = !ledIsOn; | |
digitalWrite(PIN_LED, ledIsOn); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment