LEDs

Blinking LED

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


The code

#include <CtrlLed.h>

// Digital mode example (non-PWM pin).
// This assumes you have connected your LED to a pin without the need for PWM:
CtrlLed led(LED_BUILTIN);

// 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_BUILTIN, 255);

void setup()
{
  // Initialize the LED (nothing special needed for digital mode).
}

void loop() {
  // Make the LED blink.
  led.toggle();
  delay(500);
}
Previous
LED methods