wirecraft

Music · Raspberry Pi Pico

One-String Laser Band

A Raspberry Pi Pico build with 5 components. Reads: Light sensor, Potentiometer. Drives: NeoPixel, LED, Buzzer. Fade the pixels on when the room gets dark.

5 parts · 13 connections · 10 steps

Wiring

Mini Map
power
ground
data
signal
analog

Parts

PartRefsQtyEst.
Photoresistor (LDR) + 10 kΩ dividerLightSensor1$0.40
WS2812B NeoPixel ring (8 px)NeoPixel1$3.80
LED (5 mm) + 220 Ω resistorLED1$0.15
Passive piezo buzzerBuzzer1$0.60
10 kΩ potentiometerPotentiometer1$0.50
Plus: breadboard, jumper wires, USB cable≈ $5.45

Prices are rough hobby-market estimates. Click a part for wiring notes and specs.

Firmware

src/main.cpp
1// Night Light
2// Generated by Wirecraft for the Raspberry Pi Pico (RP2040)
3// Prompt: A light-beam musical instrument where breaking a light sensor beam plays buzzer tones, with a knob for pitch
4//
5// Wiring, parts and step-by-step assembly live alongside this file.
6
7#include <Arduino.h>
8#include <Adafruit_NeoPixel.h>
9
10#define LIGHTSENSOR_PIN 26
11#define NEOPIXEL_PIN 2
12#define NEOPIXEL_COUNT 8
13#define LED_PIN 3
14#define BUZZER_PIN 6
15#define POTENTIOMETER_PIN 27
16
17int lightSensorLevel = 0;
18Adafruit_NeoPixel neoPixel(NEOPIXEL_COUNT, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
19int potentiometerValue = 0;
20
21void setup() {
22 Serial.begin(115200);
23 neoPixel.begin();
24 neoPixel.setBrightness(60);
25 neoPixel.show();
26 pinMode(LED_PIN, OUTPUT);
27 pinMode(BUZZER_PIN, OUTPUT);
28 Serial.println(F("Night Light ready."));
29}
30
31void loop() {
32 // --- Read sensors ---
33 lightSensorLevel = analogRead(LIGHTSENSOR_PIN);
34 potentiometerValue = analogRead(POTENTIOMETER_PIN);
35
36 // --- React ---
37 // Fade the pixels on when the room gets dark.
38 if (lightSensorLevel < 800) {
39 neoPixel.fill(neoPixel.Color(43, 75, 242)); neoPixel.show();
40 } else {
41 neoPixel.clear(); neoPixel.show();
42 }
43
44 delay(50);
45}
46
platformio.ini
1; PlatformIO project for Night Light
2[env:pico]
3platform = raspberrypi
4board = pico
5framework = arduino
6monitor_speed = 115200
7lib_deps =
8 adafruit/Adafruit NeoPixel@^1.12.0
9

Assembly

  1. 1

    Lay out your workbench

    Gather the Raspberry Pi Pico, 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. 2

    Seat the board and power rails

    Run a red jumper from the Raspberry Pi Pico's 3V3 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. 3

    Wire the Light sensor

    Place the Photoresistor (LDR) + 10 kΩ divider on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: SIG → GP26. Tip: LDR to VCC, 10 kΩ to GND, read the midpoint. Brighter light = higher reading.

  4. 4

    Wire the NeoPixel

    Place the WS2812B NeoPixel ring (8 px) on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: DIN → GP2. Tip: Add a 330 Ω resistor on DIN and a 470 µF cap across power for happy pixels.

  5. 5

    Wire the LED

    Place the LED (5 mm) + 220 Ω resistor on the breadboard. Power first: CATHODE → − rail. Then signals: ANODE → GP3. Tip: The longer leg is the anode (+). The resistor can go on either leg.

  6. 6

    Wire the Buzzer

    Place the Passive piezo buzzer on the breadboard. Power first: GND → − rail. Then signals: SIG → GP6. Tip: Passive buzzers need tone(); active ones just want HIGH. This design assumes passive.

  7. 7

    Wire the Potentiometer

    Place the 10 kΩ potentiometer on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: WIPER → GP27. Tip: Outer legs to VCC and GND, middle leg (wiper) to the analog pin.

  8. 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. 9

    Flash the firmware

    Open the exported folder in VS Code with the PlatformIO extension (free), plug in the Raspberry Pi Pico 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. 10

    Bring it to life

    Open the Serial Monitor at 115200 baud to watch live readings. Fade the pixels on when the room gets dark. Adjust the thresholds at the top of the sketch to match your environment.

Heads-up from the engine

  • NeoPixel prefers 5 V but Raspberry Pi Pico tops out at 3.3 V — most modules still work, but check yours.