Toothbrushtimer With the ATtiny13




Introduction: Toothbrushtimer With the ATtiny13

People often don’t brush their teeth well, or do it too quickly, especially children. This tool may help them to spend the right amount of time at the right area.

I have made and published a toothbrushtimer before, but it was not robust enough to survive long in the harsh enviroment of a bathroom, and the extra complexity of the quiz was distraction from the toothbrushing. This timer will guide you through 4 phases of 30s for each corner of the mouth, followed by 10s to clean the tongue. I have no idea what the officially recommended times are, but these seem quite reasonable to me.

The timer presented here has the following features:

  • Very short code: 724 bytes fits on a cheap 8-pin ATtiny13A microcontroller.
  • Very simple operation: just press the button to start. Goes to sleep at the end.
  • Very low power consumption in sleep mode, no need to switch off power explicitly.

Step 1: Components and Tools

I got most of these components from AliExpress for about 4 EUR.

  • ATtiny13A microcontroller. Should also work with the more powerful ATTINY85.
  • 8-pin IC socket 8x8 LED matrix controlled by MAX7219 chip. Best is a compact module without soldered headers.
  • Battery holder for 3 AAA batteries
  • Waterproof project box, 85x58x33mm
  • 16mm momentary push button
  • 10x15mm boat rocker on/off switch
  • Double-sided 3x7cm prototype board
  • 5-pin female pin header
  • 5-pin male pin header, right angle
  • Some stranded hookup wire to connect everything

Required tools:

  • Soldering iron
  • Arduino Uno to program the ATtiny13
  • Rotary tool to cut the holes in the project box
  • Hand file to fine-tune the holes in the project box
  • Hot-glue gun to fix the LED display in the box

Step 2: Schematic

The schematic is shown in the picture. I would recommend trying it out on a breadboard first.

3AAA batteries in series supply enough voltage and current to run the device, even if they are the NiMH rechargeable type. Power is supplied to both the ATtiny and the 8x8 LED module. The power can be interrupted with a switch. It is not strictly necessary, since in sleep mode the power use is small enough to last at least 2 years. Still, a power-off switch makes sense for long-time absence or when working on the circuit. 3 pins from the ATiny communicate with the MAX7219. Pin 1 of the ATtiny is connected with a push-button to ground to allow reset (and thus the start of the timing sequence)

Step 3: The Code

The code is attached. It was written as a sketch under the Arduino IDE. Follow other instructions on how to program the ATtiny using an Arduino Uno. A brief summary is below:

The easiest way to program an ATtiny chip is to use an Arduino as ISP (In System Programmer). Follow the following steps:

  • Starting up the Arduino IDE, open 'Preferences' then add for additional board managers.
  • Under 'Tools/Board', select 'Board Manager' and at the bottom of the list, install 'MicroCore by MCUdude'
  • Connect the Arduino Uno and upload 'ArduinoISP'. It is available under 'File/examples'
  • Connect the Arduino to the ATtiny, easiest done by putting the ATtiny on a prototype shield: Arduino pin 13 - ATtiny pin 7 Arduino pin 12 - ATtiny pin 6 Arduino pin 11 - ATtiny pin 5 Arduino pin 10 - ATtiny pin 1 Arduino +5v - ATtiny pin 8 Arduino GND - ATtiny pin 4
  • Choose 'Board ATtiny13', 'B.O.D 2.7V', 'Clock 1.2 MHz internal' and programmer 'Arduino as ISP' (attention: not 'ArduinoISP' but 'Arduino as ISP' )
  • Do ‘Burn Bootloader’ - there is no bootloader for the attiny, and it may give an error, but this step is needed to ‘set the fuses’ to the correct clock setting
  • Upload the attached TinyToothbrushtimer.ino

The code should be straightforward to understand and to modify. The bitmaps of the numbers are stored in program space since they won’t fit in the 64 bytes of RAM. There is no attempt at super-accurate timing. Using a 250ms delay at every ‘tick’ gave a noticeably wrong timing. Reducing the delay to 225ms got is right.

The code for communicating to the MAX7219 was copied from this project by Sanuki Udon.

Step 4: Mounting It in a Box.

Once you have it running on a breadboard, you’ll need to mound it in a solid and possibly waterproof box to get a functional device. Here’s what I did:

Mark the approximate size and position of the 3 holes on a waterproof project box With a rotary tool, cut out the holes, follow up with a hand-file for detail Mount the buttons and the LED matrix. The latter can be fixed better with some hot glue. Cut a piece of a 3x7cm double-sided prototype PCB, such that it fits. Drill two holes in the PCB corresponding to the screw-holes of the box Solder the 8-pin IC holder and the 5-pin header on the PCB Solder flexible hookup wire between the PBC, the battery-box and the buttons Solder 5 wires to the MAX7219 LED board and solder the ends to a male pin header Put in batteries, the programmed ATtiny and switch it on. If it works, close the box and start using it.

See some of the pictures for the intermediate steps.

Arduino Contest 2017

Participated in the
Arduino Contest 2017

LED Contest 2017

Participated in the
LED Contest 2017

Design For Kids Challenge

Participated in the
Design For Kids Challenge

Be the First to Share


    • Audio Challenge 2020

      Audio Challenge 2020
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Maps Challenge

      Maps Challenge

    3 Discussions


    5 months ago

    would this run from a single 18650 battery? i ask because i have these on hand and it would allow me to add usb charging.


    Reply 5 months ago

    The 18650 gives 3.7V. That's fine for the ATTINY and for the LEDs, but the datasheet of the MAX7219 says 4.0-5.5V. It might work in practice, but probably it will give up in a strange way somewhere halfway the battery life. Note that this is an extremely power-saving design, and there should be no need for the super-powered 18650 batteries. It's been running for 2y straight without ever changing batteries and without ever switching it off. The sleep mode is extremely efficient. I have some recovered 18650's but I avoid them when possible, I've seen too many videos of them going up in flames...