LED Power Budget Calculator¶
Specification¶
The full specification below is extracted from Chapter 5: Programmable LED Art with NeoPixel/WS2812B.
Type: microsim
**sim-id:** led-power-budget-calculator<br/>
**Library:** p5.js<br/>
**Template:** https://github.com/dmccreary/moving-rainbow/tree/main/docs/sims/battery-life-calculator<br/>
**Status:** Specified
Learning objective: Students will *calculate* (Bloom L3: Apply) the total current draw of a NeoPixel strip from pixel count and brightness scaling, and *evaluate* (Bloom L5: Evaluate) whether a given power supply can safely support it.
Canvas: 700x400px, responsive — recompute the gauge/readout layout from `windowWidth` inside `windowResized()`.
Controls: a `createSlider()` labeled "Pixel Count" (range 1-150, default 60); a `createSlider()` labeled "Brightness Scaling" (range 0.0-1.0, default 1.0); a `createSelect()` labeled "Power Supply" with options "Pico USB (~0.5A)," "5V 2A Wall Adapter," and "5V 5A Wall Adapter" (default: "Pico USB (~0.5A)").
Interaction: as any control changes, a live readout recalculates and displays "Worst-case current draw: X.X A" using current draw per LED (60mA) times pixel count times brightness scaling, alongside a horizontal gauge bar comparing that value to the selected power supply's rated current. The gauge bar turns green when the calculated draw is safely under the supply's rating, yellow when it's within 80-100% of the rating, and red with a flashing "Exceeds power supply!" label when the calculated draw exceeds it -- directly dramatizing the chapter's power-budget warning.
Implementation: p5.js. Recompute `currentDrawAmps = pixelCount * 0.06 * brightnessScaling` every frame from slider state; map that value onto the gauge bar's fill width and color using `map()` and conditional color logic against the selected supply's rated current. Use `createSlider()` and `createSelect()` exclusively for controls per project convention.