CTRL library / LEDs

Blinking LED

This sketch demonstrates the basic implementation of how to set up and control a blinking LED.

The code

led_blinking.ino
#include <CtrlLed.h> // The pin of the board's built-in LED. Some boards (e.g. the ESP32 Dev Module)// don't define LED_BUILTIN, so pin 2 is used there. Change it to match your wiring.#ifdef LED_BUILTINconst uint8_t LED_PIN = LED_BUILTIN;#elseconst uint8_t LED_PIN = 2;#endif // Digital mode example (non-PWM pin).// This assumes you have connected your LED to a pin without the need for PWM:CtrlLed led(LED_PIN); // PWM mode example (connect to a PWM-capable pin with brightness control):// Uncomment the line below and comment out the line above to use PWM mode// CtrlLed led(LED_PIN, 255); void setup(){  // Initialize the LED (nothing special needed for digital mode).} void loop() {  // Make the LED blink.  led.toggle();  delay(500);}