Skip to content

CPP: LED

Leo Vidarte edited this page Sep 13, 2018 · 10 revisions

A light-emitting diode (LED) is a semiconductor device that emits visible light when an electric current passes through it. The light is not particularly bright, but in most LEDs it is monochromatic, occurring at a single wavelength. The output from an LED can range from red (at a wavelength of approximately 700 nanometers) to blue-violet (about 400 nanometers). Some LEDs emit infrared (IR) energy (830 nanometers or longer); such a device is known as an infrared-emitting diode (IRED).

Schematic

Download the project

Checkout this PlatformIO project code here

Code

#include <Arduino.h>

// D0 - Internal LED (GPIO16)

void setup ()
{
  pinMode(D0, OUTPUT);
}

void loop ()
{
  // The internal LED turn on when the pin is LOW
  digitalWrite(D0, HIGH);
  delay(1000);
  digitalWrite(D0, LOW);
  delay(1000);
}

Here is the reason why the built in led turns on when Pin 16 is Low :)