Skip to content

About

Wled

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

BTL Macropad

A Wi-Fi knob-and-button pad for WLED lights, with a built-in light toy. Every button is set up from your phone, so there's no code to edit.

Install from your browser: btltech1.github.io/btl-macropad Plug in the board, click Install, and it asks for your Wi-Fi when it's done.

  • Boards: ESP32 DevKit (30 or 38 pin) or ESP32-C3 SuperMini
  • Parts: EC11 rotary encoders (with push), keyboard-style switches, hookup wire. No resistors.

Light toy modes, simulated

Features

  • Settings page on the pad (http://btl-macropad-xxxx.local): each key gets a press action and a hold action, and each dial gets turn, push and hold actions.
    • Actions: WLED preset, save the current look to a preset, cycle through presets, all WLED lights on/off, one light on/off, set color, effect or palette, brightness, start/stop/next toy mode, call any web address (Shelly switches, etc.), custom WLED JSON.
    • A Test button next to every action. Preset, effect and palette names are read from your light.
  • Finds WLED lights on your network automatically. "All lights on/off" reaches every one.
  • Instant response: the pad keeps a live connection (WebSocket) to your main light, so turning a dial goes out immediately, and WLED pushes its state back.
  • Light toy: the pad draws the animation itself and streams it to WLED's realtime mode at 50 fps. Running WLED playlists pause while you play and restart afterwards.
  • Wiring checker: shows live which pin each switch is really on. A wrong pin is a setting, not a resolder.
  • Wi-Fi setup three ways: over USB right after installing, a phone setup network (BTL-Macropad-xxxx), or Settings → Change Wi-Fi. Hold Dial 1 while plugging in to get the phone setup network back.
  • Updates over Wi-Fi (Settings → Update firmware). Optional page password. Hold both dials 10 s to erase everything.

Light toy modes

Push the toy dial to step to the next mode (the blue LED blinks the mode number).

Mode How to play
Ball Flick the dial: it flies, slows and bounces off the ends
Follow The light tracks the dial exactly
Paint Leaves a rainbow trail that stays
Wander Moves around on its own; turn to push it
Fireworks Flick to launch (harder = higher), turn to steer, it bursts into sparks
Swing Hangs in the middle; turn in rhythm to pump it higher
Spring Turn to stretch the band; stop and it snaps back and wobbles
Bounce LED 0 is the floor: turn to throw the ball up
Campfire Turn to stoke the fire; it dies down if you stop
Rain Drops twinkle; the dial blows the wind
Swarm Fireflies chase the dial position
Rain vs Fire Blue from one end, red from the other; the dial moves where they clash, with bigger explosions near the ends

The toy ends 8 s after you stop (once it's still). Ambient modes keep going until you hold the toy dial or press a preset key.

Fireworks, simulated

Wiring

Every switch goes between its pin and a shared ground wire. On each encoder, the middle pin of the 3-pin side goes to ground; one of the 2 push pins goes to its pin and the other to ground.

ESP32 DevKit default:

Control Pins
Dial 1 (brightness, push = all lights on/off) A → D32, B → D33, push → D25
Dial 2 (light toy, push = next mode, hold = stop) A → D26, B → D27, push → D14
Keys 1-9 (press = preset 1-9, hold = save to it) D23, D22, D21, D19, D18, TX2 (17), RX2 (16), D4, D13

Avoid D34, D35, VP and VN: those pins have no built-in pull-up.

ESP32-C3 SuperMini default: Dial 1 = 0 / 1 / push 3, Dial 2 = 4 / 5 / push 6, Keys 1-4 = 7, 10, 20, 21.

All pins can be changed on the settings page.

Wiring diagram One dial, close up

WLED settings

  • Config → Sync Interfaces → Realtime → "Receive UDP realtime" must be ticked (it is by default) for the light toy.
  • If the WLED app shows "Live data" with an Override button while you play, leave it alone; the pad clears it automatically the next time the toy starts.

Building from source

  1. Arduino IDE 2 with esp32 by Espressif (core 2.0.9) and the ArduinoJson library (v7).
  2. Open BTL_Macropad/BTL_Macropad.ino.
  3. Board: ESP32 Dev Module, or ESP32C3 Dev Module with USB CDC On Boot: Enabled. Default partition scheme.
  4. Upload.

The toy physics, settings, actions, Improv and WebSocket code live in header files with no Arduino calls, so they're unit-tested on a PC: tests/run.sh. GitHub runs the tests, builds both boards and publishes the installer page on every push (.github/workflows/build.yml).

Files

Path What it is
BTL_Macropad/BTL_Macropad.ino Firmware: inputs, actions, web server, Wi-Fi, toy streaming
BTL_Macropad/config.h Settings, actions, board pin lists, defaults, validation
BTL_Macropad/toy_logic.h Light toy physics and drawing, WLED realtime packets
BTL_Macropad/panel_logic.h Encoder decoding, button debounce, WLED JSON helpers
BTL_Macropad/improv.h Wi-Fi setup over USB (used by the web installer)
BTL_Macropad/ws_proto.h WebSocket framing for the live link to WLED
BTL_Macropad/setup_portal.h Phone setup network
BTL_Macropad/web_page.h The settings page
web/ Installer page (ESP Web Tools)
tests/ PC unit tests

License

MIT. See LICENSE.

About

Wled

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages