Projects / Shadow puppet theatre light

Shadow puppet theatre light

Beginner45 minGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO15.2 mA

    Wire the ring

    Add the capacitor and data resistor first.

  2. NANO

    Test the colours

    Hold each scene button and watch the fade.

  3. NANO

    Add the buttons

    Mount four large coloured buttons where children can reach them.

  4. NANO

    Tune the scenes

    Change the colours and the twinkle and lightning times.

  5. NANO

    Build the screen

    Stretch a white cloth in a frame in front of the light.

  6. NANO

    Tell a story

    Practise changing the scenes with the story.

In short

How do you build a shadow puppet theatre light?

A colour lamp behind a cloth screen changes from day to night scenes as children tell a story. You need Arduino Nano, WS2812B ring 16 LEDs, Tactile push button 6 mm × 4, 5 V 2 A USB adapter, Resistor 330 Ω and Electrolytic capacitor 1000 µF. It takes 6 steps and about 45 minutes.

Level
Beginner
Time
About 45 min
Parts
6

Parts list

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

Wiring

FromToWhy
5 V USB adapter +LED ring 5V, Nano 5V pin and capacitor +Power
5 V USB adapter -LED ring GND, Nano GND and capacitor -Common ground
1000 µF capacitorAcross 5V and GNDSmooths power
Nano D6330 Ω resistor then LED ring DINData
Day, sunset, night and storm buttonsNano D2, D3, D4, D5 and GNDScene choice

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "Adafruit NeoPixel". Brightness is set to 120 of 255 so a 2 A adapter has plenty of margin. Put the ring behind a white cloth stretched on a frame and keep the lamp, adapter and cables out of reach of small children. The storm scene flashes briefly, so avoid it for anyone sensitive to flashing lights.

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).

#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel ring(16, 6, NEO_GRB + NEO_KHZ800);
const byte BTNS[4] = { 2, 3, 4, 5 };
// Colours for day, sunset, night, storm
const byte SCENES[4][3] = { {255, 220, 120}, {255, 90, 20}, {10, 20, 90}, {40, 40, 70} };
float cur[3] = { 0, 0, 0 };
byte scene = 0;
unsigned long nextFlash = 0, flashEnd = 0;

void setup() {
  for (byte i = 0; i < 4; i++) pinMode(BTNS[i], INPUT_PULLUP);
  ring.begin();
  ring.setBrightness(120);
  randomSeed(analogRead(A0));
}

void loop() {
  for (byte i = 0; i < 4; i++) if (!digitalRead(BTNS[i])) scene = i;
  for (byte c = 0; c < 3; c++) cur[c] += (SCENES[scene][c] - cur[c]) * 0.03;      // fade between scenes
  float boost = 1.0;
  if (scene == 3) {                                                                // lightning in the storm
    if (millis() > nextFlash) { flashEnd = millis() + random(60, 160); nextFlash = millis() + random(1500, 6000); }
    if (millis() < flashEnd) boost = 6.0;
  }
  if (scene == 2) boost = 0.8 + 0.2 * sin(millis() / 700.0);                       // gentle night twinkle
  for (byte i = 0; i < 16; i++) {
    ring.setPixelColor(i, ring.Color(min(255.0f, cur[0] * boost), min(255.0f, cur[1] * boost), min(255.0f, cur[2] * boost)));
  }
  ring.show();
  delay(20);
}

Test checklist

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

CheckExpected
Power onFades up to the day scene
Press sunsetFades to orange
Press nightFades to deep blue with a slow twinkle
Press stormDark with random lightning flashes

If it does not work

Colours flicker or are wrong

Check common ground and the data resistor.

No light

Check DIN is the input and the 5 V supply.

Buttons do nothing

Check each goes to ground when pressed.

Fade too slow or fast

Change the 0.03 value in the code.

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

Ask Lark AI

Common questions

What parts do I need for the shadow puppet theatre light?

Arduino Nano, WS2812B ring 16 LEDs, Tactile push button 6 mm × 4, 5 V 2 A USB adapter, Resistor 330 Ω and Electrolytic capacitor 1000 µF.

How long does the shadow puppet theatre light take to build?

About 45 minutes for a beginner maker, in 6 steps.

How do I know the shadow puppet theatre light works?

Power on: Fades up to the day scene. Press sunset: Fades to orange. Press night: Fades to deep blue with a slow twinkle.

Colours flicker or are wrong: what should I check?

Check common ground and the data resistor.

No light: what should I check?

Check DIN is the input and the 5 V supply.

Buttons do nothing: what should I check?

Check each goes to ground when pressed.

Fade too slow or fast: what should I check?

Change the 0.03 value in the code.