Ambient · ESP32 DevKit
Sunset Mood Lamp
A ESP32 DevKit build with 5 components. Reads: Button, Potentiometer, Light sensor. Drives: NeoPixel, LED.
5 parts · 13 connections · 10 steps
Wiring
Parts
| Part | Refs | Qty | Est. |
|---|---|---|---|
| WS2812B NeoPixel ring (8 px) | NeoPixel | 1 | $3.80 |
| Tactile push button | Button | 1 | $0.10 |
| 10 kΩ potentiometer | Potentiometer | 1 | $0.50 |
| LED (5 mm) + 220 Ω resistor | LED | 1 | $0.15 |
| Photoresistor (LDR) + 10 kΩ divider | LightSensor | 1 | $0.40 |
| Plus: breadboard, jumper wires, USB cable | ≈ $4.95 | ||
Prices are rough hobby-market estimates. Click a part for wiring notes and specs.
Firmware
1// Mood Lamp2// Generated by Wirecraft for the ESP32 DevKit (ESP32-WROOM-32)3// Prompt: A mood lamp with a NeoPixel ring, a button to cycle colors and a knob for brightness4//5// Wiring, parts and step-by-step assembly live alongside this file.67#include <Arduino.h>8#include <Adafruit_NeoPixel.h>910#define NEOPIXEL_PIN 411#define NEOPIXEL_COUNT 812#define BUTTON_PIN 513#define POTENTIOMETER_PIN 3214#define LED_PIN 1315#define LIGHTSENSOR_PIN 331617Adafruit_NeoPixel neoPixel(NEOPIXEL_COUNT, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);18bool buttonPressed = false;19int potentiometerValue = 0;20int lightSensorLevel = 0;2122void setup() {23 Serial.begin(115200);24 neoPixel.begin();25 neoPixel.setBrightness(60);26 neoPixel.show();27 pinMode(BUTTON_PIN, INPUT_PULLUP);28 pinMode(LED_PIN, OUTPUT);29 Serial.println(F("Mood Lamp ready."));30}3132void loop() {33 // --- Read sensors ---34 buttonPressed = (digitalRead(BUTTON_PIN) == LOW);35 potentiometerValue = analogRead(POTENTIOMETER_PIN);36 lightSensorLevel = analogRead(LIGHTSENSOR_PIN);3738 delay(50);39}401; PlatformIO project for Mood Lamp2[env:esp32dev]3platform = espressif324board = esp32dev5framework = arduino6monitor_speed = 1152007lib_deps =8 adafruit/Adafruit NeoPixel@^1.12.09Assembly
- 1
Lay out your workbench
Gather the ESP32 DevKit, a half-size breadboard, and a bundle of male-to-male jumper wires. Keep the parts list open — every component below gets its own spot on the breadboard. Don't plug in USB power until the last wire is placed.
- 2
Seat the board and power rails
Run a red jumper from the ESP32 DevKit's 3V3 (or VIN for 5 V parts) pin to the breadboard's + rail, and a black jumper from GND to the − rail. Every component's power and ground will tap these rails.
- 3
Wire the NeoPixel
Place the WS2812B NeoPixel ring (8 px) on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: DIN → GPIO4. Tip: Add a 330 Ω resistor on DIN and a 470 µF cap across power for happy pixels.
- 4
Wire the Button
Place the Tactile push button on the breadboard. Power first: GND → − rail. Then signals: SIG → GPIO5. Tip: Legs on the same side are connected in pairs — wire diagonally opposite corners to be safe.
- 5
Wire the Potentiometer
Place the 10 kΩ potentiometer on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: WIPER → GPIO32. Tip: Outer legs to VCC and GND, middle leg (wiper) to the analog pin.
- 6
Wire the LED
Place the LED (5 mm) + 220 Ω resistor on the breadboard. Power first: CATHODE → − rail. Then signals: ANODE → GPIO13. Tip: The longer leg is the anode (+). The resistor can go on either leg.
- 7
Wire the Light sensor
Place the Photoresistor (LDR) + 10 kΩ divider on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: SIG → GPIO33. Tip: LDR to VCC, 10 kΩ to GND, read the midpoint. Brighter light = higher reading.
- 8
Double-check before power
Trace every wire against the diagram once more — 13 connections in total. The classic mistakes: swapped power and ground, and off-by-one rows on the breadboard. Thirty seconds of checking saves a component.
- 9
Flash the firmware
Open the exported folder in VS Code with the PlatformIO extension (free), plug in the ESP32 DevKit over USB, and hit Upload. PlatformIO fetches the libraries listed in platformio.ini automatically. Prefer the Arduino IDE? Copy src/main.cpp into a new sketch and install the same libraries from the Library Manager.
- 10
Bring it to life
Open the Serial Monitor at 115200 baud — you should see "Mood Lamp ready." Then start customizing the loop; the sketch is organized so every component's code is easy to find.