Codey OnlineArduino & ESP32 component library › LED
LED
Output

LED

Standard 5mm through-hole LED. Available in red, green, blue, yellow, white, orange, and warm white. Requires a current-limiting resistor (typically 220Ω for 5V).

Pinout — LED

Pin Signal Description
ANODE Positive lead (long leg, +)
CATHODE Negative lead (short leg, -)

Wiring notes

2-pin component. Use componentId led with the color in the label (e.g. Red LED). Pins: ANODE (+, long leg), CATHODE (-, short leg). Polarized — ANODE must connect to the positive side. Always use a current-limiting resistor (220Ω for 5V, 100Ω for 3.3V).

Example wiring diagram — LED

From To Wire
board:D4 bb:E5 green
r1:1 bb:A5 red
r1:2 bb:A10 blue
led1:ANODE bb:E10 yellow
led1:CATHODE bb:E11 purple
bb:B11 board:GND black

Example Arduino code — LED

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// Canonical LED example for Arduino Uno
// Blinks a red LED through a 220Ω resistor on digital pin 4.

const int ledPin = 4;

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

void loop() {
  digitalWrite(ledPin, HIGH);  // LED on
  delay(500);

  digitalWrite(ledPin, LOW);   // LED off
  delay(500);
}

Related components

3W amplifier MAX98357A I2S DAC

3W amplifier MAX98357A I2S DAC

Active Buzzer Module

Active Buzzer Module

LED Matrix Module MAX7219

LED Matrix Module MAX7219

Passive Buzzer Module

Passive Buzzer Module

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free