Bare-metal C firmware that turns an ATtiny85 into a three-speed electric-toothbrush controller.
Short press β cycle speeds Β· Long press β start / stop & ultra-low-power sleep
| Category | Highlights |
|---|---|
| βοΈ Deterministic PWM | Phase-correct 8-bit PWM via Timer0 (~16 kHz) for smooth motor control |
| π Three Speed Levels | Lookup table for 100%, 66%, and 33% motor duty cycles |
| π²οΈ One-Button UI | INT0-based ISR distinguishes between short and long presses |
| π Ultra-Low Power | < 5 Β΅A in SLEEP_MODE_PWR_DOWN mode for long battery life |
| π§© Modular Drivers | Clean, decoupled APIs for motor, button, and power subsystems |
| π Continuous Build | GitHub Actions CI on every push to main |
This project is a minimal but robust firmware for DIY or commercial electric toothbrush designs. It emphasizes low power consumption, predictable timing, and user-friendly control, while sticking to bare-metal C for full control over performance and size.
Ideal for:
- Battery-powered personal care devices
- Hobby projects involving brushed DC motors
- Learning AVR low-level development
git clone https://github.com/dondfx/attiny85-toothbrush.git
cd attiny85-toothbrush
platformio run # builds firmware.hex
platformio run -t upload # flash with USBtinyISPEnsure proper clock and power behavior by burning the correct fuses:
LFUSE 0xE2 HFUSE 0xD7 EFUSE 0xFF
To burn the fuses, use this command (replace -c usbtiny if you're using a different programmer):
avrdude -p attiny85 -c usbtiny -U lfuse:w:0xE2:m -U hfuse:w:0xD7:m -U efuse:w:0xFF:m
attiny85-toothbrush/
βββ include/ β Header files (motor.h, button.h, power.h)
βββ src/ β Source code: drivers + main
βββ hardware/
β βββ gerbers/ β PCB manufacturing files
β βββ step/ β 3D STEP model of the PCB
β βββ docs/ β Wiring diagram & connection info (PDF)
βββ .github/ β GitHub Actions CI workflow
βββ platformio.ini β PlatformIO project config
βββ BOM.md β Bill of Materials with footprints
βββ README.md β This documentation
- MCU: ATtiny85 @ 8 MHz (internal RC oscillator)
- Output: PB0 (OC0A) β Motor PWM control
- Input: PB2 (INT0) β Single button
- Power Mode: Enters SLEEP_MODE_PWR_DOWN after 2 s long press
β Stable & tested on breadboard and custom PCB
β < 5 Β΅A sleep current
π Future: H-bridge motor driver support (e.g., DRV8833)
This project is licensed under the MIT License.
Built for fun, learning, and real-world utility. Contributions welcome!
