Tutorial by Examples: blinky

One of the most straight forward way of making an LED blink is: turn it on, wait a bit, turn it off, wait again, and repeat endlessly: // set constants for blinking the built-in LED at 1 Hz #define OUTPIN LED_BUILTIN #define PERIOD 500 void setup() { pinMode(OUTPIN, OUTPUT); // sets t...
The elapsedMillis library provides a class with the same name that keeps track of the time that passed since it was created or set to a certain value: #include <elapsedMillis.h> #define OUTPIN LED_BUILTIN #define PERIOD 500 elapsedMillis ledTime; bool ledState = false; void setup...
This is very close to an example from the arduino docs: // set constants for blinking the built-in LED at 1 Hz #define OUTPIN LED_BUILTIN #define PERIOD 500 // this is in milliseconds int ledState = LOW; // millis() returns an unsigned long so we'll use that to keep track of time unsigned...

Page 1 of 1