A pill-sized LED trinket β with sand and liquid flowing inside. Shake it, tilt it, watch it flow.
PixPill is a tiny glowing gadget barely larger than a real pill capsule. On a 4-layer HDI micro PCB, it packs an STM32C011 MCU, a BMA530 accelerometer, an IS31FL3736 LED matrix driver, 96Γ micro LEDs, and an nPM1100 PMIC. The firmware runs physics-based particle simulations β tilt it and sand pours, liquid flows.
Bilibili video linkοΌClick here
Its tiny PCB dimensions (23.9Γ8.6 mm / 19.5Γ6.9 mm) are deliberately aligned with standardized size 000 (26.1Γ8.5 mm) and size 1 (19.4Γ6.9 mm) pill capsules.
For detailed hardware design and 3D-related information, see Hardware Design.md. For software details, see Software Design.md.
- γTinyγ β PCB as narrow as 6.9 mm in diameter; fits inside a real pill capsule
- Two physics modes β Sand (granular, stacks naturally) and Liquid (SPH-inspired fluid with density pressure)
- Gesture control β Shake up-down-up-down rapidly to toggle between sand and liquid modes
- Auto sleep β Enters nPM1100 ship mode (shutdown) after 22 seconds of stillness to preserve battery
- USB charging β microUSB for charging
- Fault detection β nPM1100 ERR pin triggers LED array blinking alarm, pausing normal operation
- Animated transitions β Boot, shutdown, charging, and error states each have unique LED animations
| Component | Part | Notes |
|---|---|---|
| MCU | STM32C011D6Y6TR | Cortex-M0+ @ 48 MHz, WLCSP12 (1.7Γ1.42Γ0.6 mm, 0.35 mm pitch) |
| IMU | BMA530 | 3-axis accelerometer, IΒ²C, WLCSP6 (1.2Γ0.8Γ0.55 mmΒ³) |
| LED Driver | IS31FL3736 | 12Γ8 LED matrix controller, IΒ²C paged register access, per-LED 8-bit PWM, 5Γ5 QFN |
| LEDs | 96Γ 0402 (000#) / 90Γ 0201 (1#) | Arranged in a pill-shaped layout |
| PMIC | nPM1100 | Li-Po charger, max 400 mA LDO, with ship mode |
| Battery | 08120 3.7V Li-Po | Charged via microUSB |
| PCB | 4-layer 1st-order HDI | 23.9Γ8.6 mm / 19.5Γ6.9 mm |
- Based on a cellular-automaton classic falling-sand algorithm
- 8 gravity directions, conforming to the natural angle of repose of sand
- Particles stack naturally along gravity; tilt spills them
- Frame rate adapts to tilt angle
- SPH-inspired implementation: gravity + density field pressure + inter-particle repulsion + velocity damping
- Finer sub-step integration per frame
- Inter-particle collision detection
- 18Γ6 density grid mapped to the 96-LED pill-shaped layout
- Surface tension available but currently disabled
main.c β STM32CubeMX HAL init β cpp_main() main loop
Components/
βββ Src/
β βββ cpp_main.cpp β state machine, gesture detection, main loop
β βββ bma530.cpp β BMA530 IΒ²C driver
β βββ is31fl3736.cpp β IS31FL3736 IΒ²C driver
β βββ sandsim.cpp β sand particle simulation
β βββ liquidsim.cpp β liquid particle simulation
β βββ pixpill_anim.cpp β boot / shutdown / charging / error animations
βββ Inc/ β headers + various constexpr LUTs
- No RTOS β bare-metal superloop
- State machine:
BOOT β RUNNING β SHUTDOWN - Compiler:
arm-none-eabi-g++(-Os) - Desktop simulators:
sand_visual_sim.py/liquid_visual_sim.pyβ tune particle parameters directly on PC before flashing
Pre-built firmware is also provided; flash directly via STM32 CubeProgrammer or similar tools, via SWD.
arm-none-eabi-gcctoolchain, GNU Make- VSCode + EIDE
- STM32CubeMX (v6.14+) for
.iocgeneration - STM32CubeProgrammer CLI for flashing
- First-time after soldering the battery, plug in USB β device wakes from ship mode (charging animation plays)
- Press the button β array lights up briefly, boot animation plays, then simulation starts (default: liquid mode)
- Tilt β particles flow with gravity
- Shake up-down rapidly 4 times β toggles between sand and liquid (the detection window is short to avoid interfering with normal handling β shake quickly to switch)
- Leave still for 22 seconds β shutdown animation β enters ship mode
- Array blinks "ERR" 6 times at boot β IS31FL3736 detected an LED open or short circuit
- Back LED fast blink (100 ms) & array shows "ERR" β nPM1100 fault (ERR pin active)
- Back LED breathing & array shows battery icon for 4 seconds β USB charging plugged in
- PCB: Designed in EasyEDA Professional, fabricated as 4-layer HDI
- Simulation algorithm references:
- Website: Falling Sand Simulation β Kyle W. Pfeiffer
- Website: Falling Sand
- Website: Improved Falling Sand
- Repo: CH32V203Dev β fluid_HXY
- Repo: embedded-liquid-simulation



