Skip to content
WilliTourtPublic

About

Pixel PillπŸ’Š A pill-sized LED trinket β€” with sand and liquid flowing inside. Shake it, tilt it, watch it flow.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

68 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’Š PixPill

Cover

A pill-sized LED trinket β€” with sand and liquid flowing inside. Shake it, tilt it, watch it flow.

ENGLISH | δΈ­ζ–‡

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

PixPill in Fenbid Capsule

PixPills

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.

PixPills

For detailed hardware design and 3D-related information, see Hardware Design.md. For software details, see Software Design.md.


Features

  • γ€Œ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

Hardware

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

Simulation

Sand Mode

  • 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

Liquid Mode

  • 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

Firmware Architecture

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.

Prerequisites

  • arm-none-eabi-gcc toolchain, GNU Make
  • VSCode + EIDE
  • STM32CubeMX (v6.14+) for .ioc generation
  • STM32CubeProgrammer CLI for flashing

Usage

  • First-time after soldering the battery, plug in USB β†’ device wakes from ship mode (charging animation plays)
  1. Press the button β†’ array lights up briefly, boot animation plays, then simulation starts (default: liquid mode)
  2. Tilt β†’ particles flow with gravity
  3. 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)
  4. Leave still for 22 seconds β†’ shutdown animation β†’ enters ship mode

Status Indicators

  • 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

Credits

About

Pixel PillπŸ’Š A pill-sized LED trinket β€” with sand and liquid flowing inside. Shake it, tilt it, watch it flow.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages