Build it step by step
0 of 7 doneTest the LED
Light it red, green and blue in turn.
Make it fade
Ramp the brightness up and down.
Set the timing
4 seconds up, 6 seconds down.
Add the button
Cycle through three paces.
Add the timer
Stop after 5 minutes.
Add the battery
Charge and run it unplugged.
Make the case
Print or craft a diffuser.
How do you build a breathing pace guide?
A soft light grows and shrinks at a calm 6 breaths per minute to guide relaxation. You need Seeed XIAO RP2040, WS2812B single LED module (8 mm / breakout), Li-Po battery 3.7 V 500 mAh and Tactile push button 6 mm. It takes 7 steps and about 45 minutes.
- Level
- Beginner
- Time
- About 45 min
- Parts
- 4
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| LED module VCC | XIAO 3V3 | Power (the LED works at 3.3 V) |
| LED module GND | XIAO GND | Ground |
| LED module DIN | XIAO D0 | Data |
| Button | XIAO D1 and GND | Changes pace |
| LiPo battery | XIAO BAT+ and BAT− pads | Power and charging by USB-C |
Code
Breathe in while the light grows and out while it fades. The default of 4 seconds in and 6 seconds out is 6 breaths a minute, a pace often used for relaxing exercises. This is a relaxation aid, not a medical device: do not use it to treat any condition, and stop if you feel dizzy. Press the button to switch pace; the session stops after 5 minutes and the LED goes dark. Use warm colours rather than blue at night. For the case, a pebble shape with a thin white lid diffuses the light. Install the Seeed XIAO RP2040 board package for the Arduino IDE and pick "Seeed XIAO RP2040".
Runs on a virtual Seeed XIAO RP2040 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).
// Breathing pace guide: Seeed XIAO RP2040 with one WS2812B LED. Library: Adafruit NeoPixel.
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel led(1, D0, NEO_GRB + NEO_KHZ800);
const int BTN = D1;
// Three paces: inhale ms, exhale ms (about 6, 8 and 5 breaths a minute)
const unsigned long IN_MS[3] = {4000, 4000, 3000};
const unsigned long OUT_MS[3] = {6000, 3500, 4500};
byte pace = 0;
unsigned long startAt;
const unsigned long SESSION_MS = 300000UL; // 5 minutes
void setup() {
pinMode(BTN, INPUT_PULLUP);
led.begin(); led.setBrightness(120);
startAt = millis();
}
void show(float level) { // level 0 to 1, warm colour
byte v = (byte)(level * level * 255); // square it for a smoother low end
led.setPixelColor(0, led.Color(v, v * 0.45, v * 0.15));
led.show();
}
void loop() {
static unsigned long lastBtn = 0;
if (!digitalRead(BTN) && millis() - lastBtn > 300) { pace = (pace + 1) % 3; startAt = millis(); lastBtn = millis(); }
if (millis() - startAt > SESSION_MS) { show(0); delay(100); return; } // stop after 5 minutes
unsigned long cycle = IN_MS[pace] + OUT_MS[pace];
unsigned long t = (millis() - startAt) % cycle;
float level = (t < IN_MS[pace]) ? (float)t / IN_MS[pace] : 1.0 - (float)(t - IN_MS[pace]) / OUT_MS[pace];
show(level);
delay(10);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Power on | Light swells slowly and fades |
| Button press | Pace changes, cycle restarts |
| After 5 minutes | LED goes dark |
| Breathe with it | Comfortable, no strain |
If it does not work
Light jumps in steps
Square the level and lower the brightness limit.
No light
Check DIN goes to D0 and the module faces the right way.
Wrong colour
Change NEO_GRB to NEO_RGB.
Button seems stuck
Check the other leg goes to GND.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the breathing pace guide?
Seeed XIAO RP2040, WS2812B single LED module (8 mm / breakout), Li-Po battery 3.7 V 500 mAh and Tactile push button 6 mm.
How long does the breathing pace guide take to build?
About 45 minutes for a beginner maker, in 7 steps.
How do I know the breathing pace guide works?
Power on: Light swells slowly and fades. Button press: Pace changes, cycle restarts. After 5 minutes: LED goes dark.
Light jumps in steps: what should I check?
Square the level and lower the brightness limit.
No light: what should I check?
Check DIN goes to D0 and the module faces the right way.
Wrong colour: what should I check?
Change NEO_GRB to NEO_RGB.
Button seems stuck: what should I check?
Check the other leg goes to GND.
