Arduino LED Projects: 25 Ideas from Traffic Light to LED Cube
Arduino LED projects from easy to advanced: 25 ideas with a board, LED, resistor and time table, plus tested code for a traffic light, Knight Rider and WS2812B.
Arduino LED projects are the fastest and most fun way into electronics: with one LED, one resistor and a few lines of code your first circuit is running in five minutes. LEDs aren't just for day one, either. With the same logic you can build a traffic light, a Knight Rider scanner, an electronic die, lights that dance to music, colourful WS2812B animations and a 27-LED cube. Every new project teaches you one more programming idea: digital output, arrays, loops, PWM, timing with millis(), reading buttons and making decisions from sensors.
In this guide we've collected 25 LED projects, sorted from easy to hard, in a single table. For each one you'll see which board it works on (Arduino Uno, ESP32 or Raspberry Pi Pico), which LED and how many ohms of resistance to use, and roughly how long it takes. Then we walk through compiled, tested code for six of them: a traffic light, a breathing LED, four effects on one button, a WS2812B rainbow, a PWM wave on the ESP32 and a Knight Rider with a fading tail on the Pico.

Before you start: parts and the right resistor
Almost all 25 projects use parts from the same box. An Arduino Uno starter kit covers most of them, and you can pick up the rest (WS2812B ring, 74HC595, MAX7219 module) as you go. The one rule that really matters is a series resistor for every single-colour LED. You find its value with a simple formula: R = (Vsupply − VLED) / I. On a 5 V Arduino Uno pin, a red LED (about 2.0 V) at 15 mA gives (5 − 2) / 0.015 = 200 Ω; the nearest standard value, 220 Ω, gives about 13.6 mA and keeps both the LED and the pin comfortable. If you'd rather not do the maths by hand, use the LED resistor calculator, and for the details read how to calculate an LED resistor.
| Part | Qty | Used in projects |
|---|---|---|
| Arduino Uno (or Nano) | 1 | All of them; most also work on ESP32 and Pico |
| 5 mm LEDs (red, yellow, green, blue, white) | 10–15 | 1–18 |
| 220 Ω resistors (330 Ω for the Pico) | 10–15 | One per single-colour LED |
| Push buttons | 2–3 | 5, 7, 14, 15 and the effects sketch |
| 10 kΩ potentiometer | 1 | 9 and 13 |
| LDR and 10 kΩ resistor | 1 | 10 |
| Common-cathode RGB LED | 1 | 16 |
| IR receiver (VS1838B) and remote | 1 | 17 |
| 74HC595 shift register and 8 × 470 Ω | 1 | 18 |
| WS2812B ring (24 LEDs) or strip | 1 | 19–21 |
| MAX7219 8x8 matrix module | 1–4 | 22 |
| Breadboard and jumper wires | 1 set | All of them |
25 Arduino LED projects: board, LED, resistor and time table
The times in the table are roughly how long it takes to build the circuit, write the code and test it with the parts already on your desk; if it's your first time, multiply by one and a half. The resistor column is for a 5 V Arduino Uno. On an ESP32, red, yellow and green LEDs run a little dimmer with the same resistor; on the Pico, switch to 330 Ω. Every board listed in the board column can do the project directly; only the pin numbers change.
| No. | Project | Board | LED | Resistor (5 V) | Time |
|---|---|---|---|---|---|
| 1 | Blink with an external LED | Uno, ESP32, Pico | 5 mm red | 220 Ω | 10 min |
| 2 | Two-LED flip-flop | Uno, ESP32, Pico | 2 × 5 mm | 2 × 220 Ω | 15 min |
| 3 | SOS in Morse code | Uno, ESP32, Pico | 5 mm white | 220 Ω | 20 min |
| 4 | Traffic light | Uno, ESP32, Pico | Red, yellow, green | 3 × 220 Ω | 30 min |
| 5 | Pedestrian crossing with button | Uno, ESP32, Pico | 5 × 5 mm | 5 × 220 Ω + button | 45 min |
| 6 | Police lights | Uno, ESP32, Pico | Red + blue | 2 × 220 Ω | 20 min |
| 7 | Toggle an LED with a button | Uno, ESP32, Pico | 5 mm | 220 Ω + button | 30 min |
| 8 | Breathing LED (PWM) | Uno, ESP32, Pico | 5 mm | 220 Ω | 20 min |
| 9 | Potentiometer dimmer | Uno, ESP32, Pico | 5 mm white | 220 Ω + 10 kΩ pot | 20 min |
| 10 | LDR night light | Uno, ESP32, Pico | 5 mm white | 220 Ω + LDR + 10 kΩ | 30 min |
| 11 | LED chaser | Uno, ESP32, Pico | 8 × 5 mm | 8 × 220 Ω | 30 min |
| 12 | Knight Rider scanner | Uno, ESP32, Pico | 8 × 5 mm red | 8 × 220 Ω | 40 min |
| 13 | LED bar graph | Uno, ESP32 | 8–10 LEDs or an LED bar | 220 Ω (per LED) | 45 min |
| 14 | Electronic die | Uno, ESP32 | 7 × 5 mm | 7 × 220 Ω + button | 1 h |
| 15 | Reaction time game | Uno, ESP32, Pico | 2 × 5 mm | 2 × 220 Ω + 2 buttons | 1 h |
| 16 | RGB LED colour mixing | Uno, ESP32, Pico | Common-cathode RGB | 3 × 220 Ω | 30 min |
| 17 | LEDs controlled by a remote | Uno, ESP32 | 3 × 5 mm | 3 × 220 Ω + IR receiver | 45 min |
| 18 | 8 LEDs from 3 pins with a 74HC595 | Uno, ESP32, Pico | 8 × 5 mm | 8 × 470 Ω | 1 h |
| 19 | WS2812B rainbow ring | Uno, ESP32, Pico | 24-LED WS2812B ring | 330 Ω data + 1000 µF | 30 min |
| 20 | WS2812B comet | Uno, ESP32, Pico | WS2812B strip | 330 Ω data + 1000 µF | 45 min |
| 21 | Sound-reactive VU meter | Uno, ESP32 | WS2812B strip | 330 Ω + sound sensor | 2 h |
| 22 | Scrolling text on an 8x8 matrix | Uno, ESP32 | MAX7219 matrix | Built into the module | 1.5 h |
| 23 | LEDs controlled from your phone (Wi-Fi) | ESP32 | 3 × 5 mm | 3 × 150–220 Ω | 1 h |
| 24 | 12 V RGB LED strip | Uno, ESP32 | 12 V 5050 strip | 3 MOSFETs + 220 Ω and 10 kΩ | 1.5 h |
| 25 | 3x3x3 LED cube | Uno | 27 × 5 mm | 9 × 220 Ω + 3 transistors | 4–6 h |
Level 1: from a single LED to a traffic light (projects 1–8)
The first eight projects teach digital outputs and timing. You can do them back to back on one breadboard without rebuilding the circuit: put the LED cathodes (short legs) on the breadboard's negative rail and wire their resistors to the pins starting at D2. Leave D0 and D1 unconnected; those two pins are used when you upload code over USB, and an LED on them can break the upload.
- 1. Blink with an external LED: Blink an LED on the breadboard once a second instead of the one on the board. It's the project where you meet digitalWrite() and delay(); legs and polarity are covered in what is an LED.
- 2. Two-LED flip-flop: Two LEDs take turns; while one is on, the other is off. Drop the delay to 10 ms and your eye thinks both are lit at once. That's the first step towards multiplexing, the trick used in LED cubes and matrices.
- 3. SOS in Morse code: Send three short, three long and three short flashes using short (200 ms) and long (600 ms) blinks. It teaches you to move repeated code into a function and pass it parameters.
- 4. Traffic light: Light the red, yellow and green LEDs in the order of a real junction. Start with the code below; pedestrian and junction versions are in the Arduino traffic light guide.
- 5. Pedestrian crossing with a button: Use three LEDs for cars and two for pedestrians. When someone presses the button, the car light goes through yellow to red and the green walking light comes on. For button wiring, see how to connect a button to Arduino.
- 6. Police lights: The red and blue LEDs flash quickly three times each, then swap sides. Short 50 ms delays and two nested for loops give a convincing emergency-light effect.
- 7. Toggle an LED with a button: Each press flips the LED's state. Here you learn to catch the moment the button is pressed and to filter out contact bounce (debouncing); you'll reuse both ideas in every project with a button.
- 8. Breathing LED: analogWrite() slowly raises and lowers the brightness, like the sleep light on a laptop. It only works on the PWM pins marked ~ (3, 5, 6, 9, 10, 11 on the Uno); the idea is explained in what is PWM.
Traffic light code (project 4)
Connect the red LED to D2, yellow to D3 and green to D4, each through a 220 Ω resistor. The sketch uses a small function that sets all three LEDs and then waits, so every phase of the light is a single line and changing the timings is easy.
1// Proje 4: Trafik lambası / Traffic light
2const int RED = 2; // kırmızı LED, 220 Ω ile / red LED via 220 Ω
3const int YELLOW = 3; // sarı LED / yellow LED
4const int GREEN = 4; // yeşil LED / green LED
5
6void setup() {
7 pinMode(RED, OUTPUT);
8 pinMode(YELLOW, OUTPUT);
9 pinMode(GREEN, OUTPUT);
10}
11
12// Üç LED'i ayarla ve bekle / set all three LEDs and wait
13void light(int r, int y, int g, unsigned long ms) {
14 digitalWrite(RED, r);
15 digitalWrite(YELLOW, y);
16 digitalWrite(GREEN, g);
17 delay(ms);
18}
19
20void loop() {
21 light(HIGH, LOW, LOW, 5000); // kırmızı 5 s / red 5 s
22 light(LOW, LOW, HIGH, 4000); // yeşil 4 s / green 4 s
23 for (int i = 0; i < 3; i++) { // yeşil 3 kez yanıp söner / green flashes 3 times
24 light(LOW, LOW, LOW, 300);
25 light(LOW, LOW, HIGH, 300);
26 }
27 light(LOW, HIGH, LOW, 2000); // sarı 2 s / yellow 2 s
28}The green light flashes three times before it goes out, as it does in Austria and several other countries; if you don't want that, just delete the for loop. Red lasts much longer at a real junction, but for a model, short timings keep onlookers interested. The only weakness of this code is delay(): while the board is waiting it can't look at a button. When you add a pedestrian button, switch to timing with millis().
Breathing LED and dimmer code (projects 8 and 9)
This sketch combines two projects: the LED on D9 breathes slowly, and the potentiometer on A0 sets the peak brightness of each breath. Connect the pot's outer legs to 5V and GND and its middle leg (wiper) to A0. The brightness isn't taken straight from the counter but from the counter squared, because your eye doesn't see brightness linearly and notices small changes at low levels far more. Thanks to the squared curve, the breath opens slowly, then faster, and looks much more natural.
1// Projeler 8-9: Nefes alan LED + potansiyometreyle tepe parlaklık
2// Projects 8-9: breathing LED + pot sets the peak brightness
3const int LED_PIN = 9; // PWM pini (~) / PWM pin (~)
4const int POT_PIN = A0; // potansiyometre orta bacak / pot wiper
5
6void setup() {
7 pinMode(LED_PIN, OUTPUT);
8}
9
10// Karesel eğri: göz düşük parlaklıkta daha hassastır / squared curve: the eye is more sensitive at low levels
11void setLevel(int i, int peak) {
12 analogWrite(LED_PIN, (long)i * i / 255 * peak / 255);
13}
14
15void loop() {
16 int peak = map(analogRead(POT_PIN), 0, 1023, 10, 255); // tepe parlaklık / peak brightness
17 for (int i = 0; i <= 255; i++) { // yavaşça aç / fade in
18 setLevel(i, peak);
19 delay(6);
20 }
21 for (int i = 255; i >= 0; i--) { // yavaşça kapat / fade out
22 setLevel(i, peak);
23 delay(6);
24 }
25 delay(400); // nefes arası / pause between breaths
26}Level 2: sensors and multi-LED projects (projects 9–17)
- 9. Potentiometer dimmer: Read 0–1023 with analogRead(), scale it to 0–255 with map() and use it as the LED brightness. What is a potentiometer covers the wiring and the reading code in detail.
- 10. LDR night light: The LED switches on by itself when the room gets dark. The LDR and a 10 kΩ resistor form a voltage divider; leaving a gap of a few counts between the on and off thresholds (hysteresis) stops flicker at dusk. Details in the LDR light sensor guide.
- 11. LED chaser: A single light runs from left to right across eight LEDs. It teaches you to put pin numbers in an array and walk through it with a for loop; the same code works unchanged with 4 or 12 LEDs.
- 12. Knight Rider scanner: The light bounces back and forth between the two ends, just like the front of KITT, the talking car from Knight Rider. For a speed pot and a fading tail, see the Knight Rider and LED chaser guide.
- 13. LED bar graph: A bar of 8 or 10 LEDs fills up according to a potentiometer or sensor reading. It's the basis of battery, volume and water-level indicators; a single map() line turns the reading into the number of LEDs to light.
- 14. Electronic die: Press the button and seven LEDs show the pips of a die face, with random() picking a number from 1 to 6. Because opposite pips always light together, you can drive all 7 LEDs from only 4 pins: the centre pip, two diagonal pairs and the middle-row pair.
- 15. Reaction time game: The LED lights up at a random moment, and the faster the player hits the button, the better. The time measured with millis() is printed to the Serial Monitor; add a second button and it becomes a two-player race. Most people react in 200–300 ms.
- 16. RGB LED colour mixing: Mix the red, green and blue chips inside one LED with PWM to get hundreds of colours. For the difference between common anode and common cathode, read how to use an RGB LED.
- 17. LEDs controlled by a remote: Switch LEDs on and off and change their brightness with the buttons of a TV remote. With the IRremote library you read each button's code and use it in a switch-case; the steps are in IR receiver and remote.
Four effects on one button: chaser, scanner, filling bar and twinkle
This sketch combines projects 11, 12 and 13 in one circuit and moves to the next effect every time you press the button. Connect eight LEDs to D2–D9 through 220 Ω resistors, one leg of the button to D12 and the other to GND. Because it uses the internal pull-up resistor (INPUT_PULLUP), no external resistor is needed: the pin reads HIGH when the button is released and LOW while it's pressed.
1// Projeler 11-13: Tek butonla 4 LED efekti / 4 LED effects with one button
2const int LEDS[] = {2, 3, 4, 5, 6, 7, 8, 9}; // soldan sağa LED pinleri / LED pins, left to right
3const int N = sizeof(LEDS) / sizeof(LEDS[0]);
4const int BUTTON = 12; // buton GND'ye / button to GND (INPUT_PULLUP)
5const unsigned long STEP_MS = 80; // efekt hızı / effect speed
6
7int effect = 0; // 0 yürüyen, 1 karaşimşek, 2 dolan bar, 3 yıldız / 0 chase, 1 scanner, 2 bar, 3 twinkle
8unsigned long counter = 0; // efekt adımı / effect step
9unsigned long lastStep = 0;
10unsigned long lastPress = 0;
11bool lastButton = HIGH;
12
13// Yalnız bir LED'i yak / light only one LED
14void showOnly(int idx) {
15 for (int i = 0; i < N; i++) digitalWrite(LEDS[i], i == idx ? HIGH : LOW);
16}
17
18void setup() {
19 for (int i = 0; i < N; i++) pinMode(LEDS[i], OUTPUT);
20 pinMode(BUTTON, INPUT_PULLUP);
21 randomSeed(analogRead(A5)); // boş analog pinden tohum / seed from a floating analog pin
22}
23
24void loop() {
25 bool now = digitalRead(BUTTON);
26 if (now == LOW && lastButton == HIGH && millis() - lastPress > 200) { // basma anı + debounce / press edge + debounce
27 effect = (effect + 1) % 4;
28 counter = 0;
29 lastPress = millis();
30 }
31 lastButton = now;
32
33 if (millis() - lastStep < STEP_MS) return; // zamanı gelmediyse çık / not time yet
34 lastStep = millis();
35
36 switch (effect) {
37 case 0: // yürüyen LED / chaser
38 showOnly(counter % N);
39 break;
40 case 1: { // karaşimşek 0..7..1 / scanner 0..7..1
41 int pos = counter % (2 * N - 2);
42 showOnly(pos < N ? pos : 2 * N - 2 - pos);
43 break;
44 }
45 case 2: { // dolan ve boşalan bar / filling and emptying bar
46 int lvl = counter % (2 * N);
47 int lit = lvl <= N ? lvl : 2 * N - lvl;
48 for (int i = 0; i < N; i++) digitalWrite(LEDS[i], i < lit ? HIGH : LOW);
49 break;
50 }
51 case 3: // rastgele yıldız / random twinkle
52 digitalWrite(LEDS[random(N)], random(2));
53 break;
54 }
55 counter++;
56}The key idea of this code is that it never uses delay(). On every pass, loop() reads the button first, then uses millis() to check whether 80 ms have passed since the last step; if not, it returns straight away. That way a button press is never missed, whatever step the effect is on. The 200 ms window filters out contact bounce. One round of the scanner is 2 × 8 − 2 = 14 steps; the return path skips the last and first LED so the end LEDs don't stay on twice as long. To change the speed, play with STEP_MS or read it from a potentiometer.
Level 3: addressable LEDs, matrices, strips and an LED cube (projects 18–25)
- 18. 8 LEDs from 3 pins with a 74HC595: A shift register creates eight outputs from just three Arduino pins, and you can chain two chips for 16 LEDs. Because the chip's total current limit is low, each LED gets 470 Ω. Wiring and code are in the 74HC595 shift register guide.
- 19. WS2812B rainbow ring: Colours rotate continuously around a 24-LED ring. Each LED has its own driver chip inside, so one data pin is enough; everything else is in the WS2812B NeoPixel guide.
- 20. WS2812B comet: A bright head races along the strip with a tail that fades out behind it. Dimming every LED by a quarter at each step creates the tail all by itself.
- 21. Sound-reactive VU meter: The loudness picked up by a sound sensor becomes a bar that fills from green to red on the strip. The complete build is in music-reactive LEDs.
- 22. Scrolling text on an 8x8 matrix: Line up four MAX7219 modules and scroll your name or the time with the MD_Parola library. The driver limits the current itself, so the LEDs don't need resistors; see MAX7219 LED matrix.
- 23. LEDs controlled from your phone: The ESP32 joins your home network and serves a web page, and you switch LEDs with buttons on your phone. If you want to drive WS2812B LEDs without writing any code, see how to install WLED.
- 24. 12 V RGB LED strip: Drive a 12 V 5050 strip under kitchen cabinets or behind a desk with three MOSFETs; the Arduino only controls the gates, the power supply provides the current. Details in RGB LED strip control.
- 25. 3x3x3 LED cube: With 27 LEDs, 9 columns and 3 layers, the cube teaches multiplexing and soldering at the same time. Light the layers one after another fast enough and your eye sees the whole cube lit at once; the build steps are in the LED cube guide.
WS2812B rainbow and comet code (projects 19 and 20)

Connect the ring's DIN to D6 through a 330 Ω resistor, 5V to 5 V and GND to GND; if you use a separate power supply, its GND and the Arduino's GND must be joined. Install the Adafruit NeoPixel library from the Library Manager. The sketch shows a rainbow for 10 seconds and a blue comet for 10 seconds; you can change the colours and durations inside loop().
1// Projeler 19-20: WS2812B gökkuşağı ve kuyruklu yıldız / WS2812B rainbow and comet
2#include <Adafruit_NeoPixel.h>
3
4const int DATA_PIN = 6; // DIN, 330 Ω üzerinden / DIN via 330 Ω
5const int NUM_LEDS = 24; // 24'lü halka / 24-LED ring
6Adafruit_NeoPixel ring(NUM_LEDS, DATA_PIN, NEO_GRB + NEO_KHZ800);
7
8void setup() {
9 ring.begin();
10 ring.setBrightness(60); // 0-255, akımı sınırlar / limits the current
11 ring.show(); // hepsini söndür / all off
12}
13
14// Halka boyunca dönen gökkuşağı / rainbow rotating around the ring
15void rainbowFor(unsigned long ms) {
16 unsigned long start = millis();
17 uint16_t hue = 0;
18 while (millis() - start < ms) {
19 for (int i = 0; i < NUM_LEDS; i++) {
20 uint16_t h = hue + (uint32_t)i * 65536 / NUM_LEDS;
21 ring.setPixelColor(i, ring.gamma32(ring.ColorHSV(h)));
22 }
23 ring.show();
24 hue += 256;
25 delay(20);
26 }
27}
28
29// Parlak baş, sönen kuyruk / bright head, fading tail
30void cometFor(uint32_t color, unsigned long ms) {
31 unsigned long start = millis();
32 int head = 0;
33 while (millis() - start < ms) {
34 for (int i = 0; i < NUM_LEDS; i++) { // her adımda %25 söndür / dim every LED by 25%
35 uint32_t c = ring.getPixelColor(i);
36 uint8_t r = (c >> 16) & 0xFF, g = (c >> 8) & 0xFF, b = c & 0xFF;
37 ring.setPixelColor(i, r * 3 / 4, g * 3 / 4, b * 3 / 4);
38 }
39 ring.setPixelColor(head, color); // baş tam renkte / head at full colour
40 ring.show();
41 head = (head + 1) % NUM_LEDS;
42 delay(40);
43 }
44}
45
46void loop() {
47 rainbowFor(10000); // 10 s gökkuşağı / 10 s rainbow
48 cometFor(ring.Color(0, 120, 255), 10000); // 10 s mavi kuyruklu yıldız / 10 s blue comet
49}LED projects with the ESP32: PWM on every pin
Most projects in the table also run on an ESP32, but watch out for three differences. First, the ESP32 runs at 3.3 V: with 220 Ω a red LED gets about 6 mA, while blue and white LEDs, whose forward voltage (about 3.1 V) is very close to 3.3 V, stay dim; use 47–68 Ω for those. Second, GPIO 6–11 are wired to the board's flash memory and 34–39 are input-only, so connect LEDs to pins like 18, 19, 21, 22, 23, 25, 26 and 27. Third, PWM comes from the LEDC unit and almost every pin can output it. The code below sends a flowing wave of light across three LEDs on GPIO 18, 19 and 21 and compiles on both the 2.x and 3.x versions of the ESP32 core. If the board is new to you, start with what is an ESP32.
1// ESP32: 3 LED'de PWM ışık dalgası (çekirdek 2.x ve 3.x) / PWM light wave on 3 LEDs (core 2.x and 3.x)
2const int PINS[] = {18, 19, 21}; // LED'ler 150-220 Ω ile / LEDs via 150-220 Ω
3const int FREQ = 5000; // PWM frekansı (Hz) / PWM frequency (Hz)
4const int RES = 8; // 8 bit: 0-255
5
6void pwmWrite(int idx, int duty) {
7#if ESP_ARDUINO_VERSION_MAJOR >= 3
8 ledcWrite(PINS[idx], duty); // 3.x: pin numarasıyla / by pin number
9#else
10 ledcWrite(idx, duty); // 2.x: kanal numarasıyla / by channel number
11#endif
12}
13
14void setup() {
15 for (int i = 0; i < 3; i++) {
16#if ESP_ARDUINO_VERSION_MAJOR >= 3
17 ledcAttach(PINS[i], FREQ, RES);
18#else
19 ledcSetup(i, FREQ, RES); // kanal i / channel i
20 ledcAttachPin(PINS[i], i);
21#endif
22 }
23}
24
25void loop() {
26 float t = millis() / 1000.0;
27 for (int i = 0; i < 3; i++) {
28 float s = (sin(t * 2.0 - i * 2.1) + 1.0) / 2.0; // her LED 120° geride / each LED 120° behind
29 pwmWrite(i, (int)(s * s * 255)); // karesel eğri / squared curve
30 }
31 delay(10);
32}LED projects with the Raspberry Pi Pico and MicroPython
On the Pico all pins are 3.3 V too, and every GP pin can output PWM. The on-board LED is on GP25 on the Pico; on the Pico W it's driven through the Wi-Fi chip, so you use it as Pin("LED"). In MicroPython you set brightness from 0 to 65535 with duty_u16(). The code below runs a Knight Rider with a fading tail on six LEDs connected to GP9–GP14 through 330 Ω: at each step the head LED lights at full brightness and the others drop to a little under half of their previous level. Save it to the Pico as main.py with Thonny and it runs by itself at every power-up; for the first setup, see what is the Raspberry Pi Pico.
1# Pico: 6 LED'de kuyruklu karaşimşek (GP9-GP14) / Knight Rider with a fading tail on 6 LEDs
2from machine import Pin, PWM
3import time
4
5PINS = [9, 10, 11, 12, 13, 14] # LED'ler 330 Ω ile / LEDs via 330 Ω
6leds = []
7for p in PINS:
8 pwm = PWM(Pin(p))
9 pwm.freq(1000) # 1 kHz, titreme görünmez / no visible flicker
10 leds.append(pwm)
11
12level = [0] * len(leds) # her LED'in parlaklığı / brightness of each LED
13order = list(range(len(leds))) + list(range(len(leds) - 2, 0, -1)) # 0..5..1
14
15while True:
16 for head in order:
17 level[head] = 65535 # baş tam parlak / head at full brightness
18 for i, pwm in enumerate(leds):
19 pwm.duty_u16(level[i])
20 level[i] = level[i] * 45 // 100 # kuyruk her adımda söner / the tail fades each step
21 time.sleep_ms(70)Common mistakes and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| The LED doesn't light at all | The LED is backwards, or both legs are in the same breadboard row | Long leg to the resistor, short leg to GND; put the legs in different rows |
| The LED is very dim | pinMode(OUTPUT) is missing, or the resistor is far too big (e.g. 10 kΩ) | Add pinMode in setup(); 220 Ω is red-red-brown |
| analogWrite() doesn't change the brightness | The LED is on a non-PWM pin | Use pin 3, 5, 6, 9, 10 or 11 on the Uno |
| The code won't upload | An LED or button is on D0/D1 | Leave those two pins unused and start the circuit at D2 |
| One press is detected several times | Mechanical contact bounce | Detect the press edge and add a 50–200 ms debounce window |
| WS2812B shows random colours or stays dark | No common GND, the strip is wired from the DOUT end, or the pin in the code is wrong | Join the grounds, connect at the DIN end where the arrows start, check DATA_PIN |
| The board keeps resetting | Too many LEDs are powered from the board's 5V pin | Lower the brightness or use a separate 5 V supply |
Which project should you start with?
If you've never used an Arduino, do projects 1, 4, 7 and 8 in that order; by the end of a weekend you'll know digital output, button reading and PWM. If you have some experience, use 11, 14 and 15 to practise arrays, random numbers and millis(). Looking for a school project or a gift? Projects 19, 21 and 25 get the biggest reactions, and an LED cube always draws a crowd at a science fair. For more inspiration, browse our Arduino project ideas.
Many of the projects on this list are ready to build in the BlueGrays app: you can put together the traffic light, police lights, Knight Rider, LDR night light, RGB colour fade and WS2812B animations step by step, with circuit diagrams, parts lists and commented code.
Frequently asked questions
What resistor should I use for Arduino LED projects?
For single-colour 5 mm LEDs on a 5 V Arduino Uno, 220 Ω is the most common and safest choice; it lets about 13 mA through a red LED. On an ESP32 use 150–220 Ω for red, yellow and green LEDs, and 330 Ω on a Raspberry Pi Pico. For an exact value, use R = (V − Vf) / I.
How many LEDs can I connect to an Arduino?
In theory the Uno's 20 pins (D0–D13 and A0–A5) can drive 20 LEDs, but the total current must stay under 200 mA and D0/D1 should stay unused; with 220 Ω, lighting 12–14 LEDs at once stays within safe limits. For more, use a 74HC595 shift register, a MAX7219 driver or a WS2812B strip that runs hundreds of LEDs from one pin.
What happens if I connect an LED without a resistor?
Nothing limits the current, so the LED and the pin draw far too much. The LED shines very brightly at first, then dims or dies completely, and the Arduino pin can be permanently damaged by exceeding its 40 mA absolute maximum. A circuit that seems to work for a few minutes is not a safe circuit.
Can WS2812B LEDs be powered from the Arduino's 5V pin?
For a few LEDs at low brightness, yes; on a USB-powered Uno the total current should stay under 500 mA. Each LED can draw 60 mA at full white, so beyond 8–10 LEDs use a separate 5 V supply, join the grounds and limit the brightness with setBrightness().
What is the easiest Arduino LED project for beginners?
Blink with an external LED and the traffic light are the easiest; with one LED, a resistor and a few wires they take 10–30 minutes. After that, the button toggle and the breathing LED teach button reading and PWM, which you'll use in almost every later project.
Why doesn't analogWrite work on every pin?
On the Arduino Uno, hardware PWM only exists on the pins marked ~: 3, 5, 6, 9, 10 and 11. On other pins analogWrite() turns the LED off for values below 128 and fully on above that, with nothing in between. On the ESP32 and Raspberry Pi Pico, almost every GPIO pin can output PWM.
Projects to build after reading this
See all projects
LED Blink
The very first hello of electronics: switching a single LED on and off. The Arduino turns the LED on and off at short intervals, so the light blinks quickly.

Traffic Light
A tiny copy of the traffic light you see on the road every day. Red stays on for two seconds, yellow flashes for a moment, green stays on for two seconds, then it goes back to red through yellow…

LED Police Lights
Just like the lights on a police car: the red LED flashes three times in quick succession, then the blue LED flashes three times, and the pattern keeps repeating without a break.

Knight Rider LED Effect
The classic scanner light: a dot of light slides from one end of six LEDs to the other and then comes back.

Knight Rider LED Effect with Adjustable Speed
A light runs from one end of six LEDs to the other, turns around and runs back again.

Night Light with Ldr
A little night light that turns on by itself when it gets dark and goes off when morning comes.

Smooth Color Transition with RGB Led
A single RGB LED drifts slowly from red to green, green to blue and back to red, looping through the rainbow without ever stopping.

WS2812B Animation 1
On a strip of 56 LEDs, all the colours of the rainbow line up side by side and flow without ever stopping, as if a river of light were gliding along the strip.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32 and Pico projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

