Projects / Diwali LED light patterns

Diwali LED light patterns

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO19.3 mA

    Wire the strip

    Add the capacitor, data resistor and shared ground.

  2. NANO19.3 mA

    Test a short strip

    Try a few pixels and a fill with one colour.

  3. NANO

    Upload the sketch

    The chase pattern runs.

  4. NANO

    Change pattern

    Press the button.

  5. NANO

    Tune the brightness

    Change BRIGHT and check the supply and wires stay cool.

  6. NANO19.4 mA

    Feed both ends

    Add power at both ends of the full strip.

  7. NANO19.4 mA

    Fit it

    Stick the strip along a window or frame away from anything that burns.

In short

How do you build a diwali LED light patterns?

An Arduino runs chasing, twinkling and fading patterns on a WS2812 strip, with a button to change the pattern for festivals. You need Arduino Nano, WS2812B strip 5 m (30 LEDs/m), 5 V 2 A USB adapter, Resistor 330 Ω, Electrolytic capacitor 1000 µF, Tactile push button 6 mm and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
5 V supply +Strip + and the 1000 µF capacitor +Strip power
5 V supply -Strip - and capacitor - and Nano GNDCommon ground
Nano D6330 Ω resistor then strip DINData line
Nano 5V5 V supply +Power the Nano from the same supply on its 5V pin
ButtonNano D2 and GNDNext pattern

Code

Each pixel can draw about 60 mA at full white, so 150 pixels could demand about 9 A, far more than a typical adapter provides. The code limits brightness to 60 out of 255, and most patterns light only some of the pixels, so a 5 V 4 A supply is comfortable for the full 5 m; use a smaller section on a smaller supply. Feed power in at both ends of a long strip, with thick wires, to avoid the colours going orange at the far end. The 1000 µF capacitor across the supply and the 330 Ω resistor on the data line protect the first pixel from switch-on surges. Use only low-voltage 5 V power; the mains is inside the sealed adapter. Keep the strip off flammable decorations and do not leave it on unattended overnight. Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Library: Adafruit NeoPixel. Patterns are non-blocking, so the button always responds.
#include <Adafruit_NeoPixel.h>

const int NUM = 150;
const byte PIN = 6, BTN = 2;
const byte BRIGHT = 60;                 // capped so the supply copes
Adafruit_NeoPixel strip(NUM, PIN, NEO_GRB + NEO_KHZ800);

byte pattern = 0;
const byte PATTERNS = 4;
bool lastBtn = HIGH;
unsigned long lastFrame = 0;
uint16_t t = 0;

uint32_t gold(byte level) { return strip.Color(level, level * 0.6, 0); }

void chase() {                           // marigold dots running along the strip
  strip.clear();
  for (int i = 0; i < NUM; i += 5) strip.setPixelColor((i + t) % NUM, gold(255));
}
void twinkle() {                         // random sparkles that fade
  for (int i = 0; i < NUM; i++) {
    uint32_t c = strip.getPixelColor(i);
    byte r = (c >> 16) & 255, g = (c >> 8) & 255;
    strip.setPixelColor(i, strip.Color(r * 0.85, g * 0.85, 0));
  }
  if (random(3) == 0) strip.setPixelColor(random(NUM), gold(255));
}
void breathe() {                         // slow warm glow
  byte lvl = 40 + 100 * (1 + sin(t * 0.05)) / 2;
  for (int i = 0; i < NUM; i++) strip.setPixelColor(i, gold(lvl));
}
void rainbow() {
  for (int i = 0; i < NUM; i++) strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(t * 256 + i * 600)));
}

void setup() {
  pinMode(BTN, INPUT_PULLUP);
  strip.begin();
  strip.setBrightness(BRIGHT);
  strip.show();
}

void loop() {
  bool b = digitalRead(BTN);
  if (b == LOW && lastBtn == HIGH) { pattern = (pattern + 1) % PATTERNS; strip.clear(); delay(30); }
  lastBtn = b;

  if (millis() - lastFrame > 30) {       // about 30 frames per second
    lastFrame = millis();
    t++;
    switch (pattern) {
      case 0: chase(); break;
      case 1: twinkle(); break;
      case 2: breathe(); break;
      case 3: rainbow(); break;
    }
    strip.show();
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Power onGold chase
Button pressedNext pattern
Full brightness testSupply and wires stay cool
Far end of the stripColour matches the start with power feeding at both ends

If it does not work

First LED wrong colour

Check the 330 Ω resistor and the ground.

Whole strip flickers

Check the shared ground and the capacitor.

Colours fade to orange at the end

Add power at the far end.

Nano resets

Power it from the same 5 V supply, not from the USB.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the diwali LED light patterns?

Arduino Nano, WS2812B strip 5 m (30 LEDs/m), 5 V 2 A USB adapter, Resistor 330 Ω, Electrolytic capacitor 1000 µF, Tactile push button 6 mm and Jumper wires male to male (40 pcs, 20 cm). 5 V 2 A USB adapter: Use 5 V 4 A for the full 5 m.

How long does the diwali LED light patterns take to build?

About 90 minutes for a beginner maker, in 7 steps.

How do I know the diwali LED light patterns works?

Power on: Gold chase. Button pressed: Next pattern. Full brightness test: Supply and wires stay cool.

First LED wrong colour: what should I check?

Check the 330 Ω resistor and the ground.

Whole strip flickers: what should I check?

Check the shared ground and the capacitor.

Colours fade to orange at the end: what should I check?

Add power at the far end.

Nano resets: what should I check?

Power it from the same 5 V supply, not from the USB.