Thursday, 8 September 2016

Make Your Own Toothbrush Timer with Circuit Playground

We've made a toothbrush timer using an Adafruit Circuit Playground board.

Getting kids to understand how long to brush their teeth for and how to spend enough time on each part of their mouth can be tricky. There are apps available but my kids' devices are on charge and not near the bathroom when they are cleaning their teeth.

You can buy toothbrush timers but it's more fun to make your own! I'm keen to make sure my kids understand how tech can be used to make useful everyday devices rather than just seeing gadgets as black boxes. This is a great project for developing their design thinking skills and understanding the benefits of making your own gadgets. 

This project is perfect for microprocessor learning board that include onboard LEDs. You could use a BBC micro:bit, a Code Bug or a Circuit Playground. We went with the Circuit Playground for this project because it has coloured LEDs and a built in tone buzzer for playing sounds. (You could add a speaker to the other devices and cope with just using red LEDs.)


If you want to make this project you'll need:

Toothbrush Timer Algorithm

The Circuit Playground board has a ring of 10 RGB LEDs. We started off following the advice to spend 30 seconds on each quadrant of the mouth and used the LEDs as a visual reminder of which area they should be cleaning and where they have already cleaned.

We lit up 3 LEDs to indicate the quadrant that should be being brushed and make them flash for 30 seconds, then we moved on to the next quadrant until the whole mouth has been covered for a total of 2 minutes. 

We added a beep in between each quadrant as a reminder to move on to the next quadrant. The lights in a quadrant turn green once it has been completed. 

Once the cycle has been completed the Circuit Playground plays some 'success' beeps. 

A toothbrushing cycle is triggered by pressing the left button on the Circuit Playground.

Testing and Tweaking

We tested this version of the code for a couple of days and spotted a problem. The kids were spending more time on their back teeth than their front teeth. Although the advice is to spend 30 seconds on each quadrant we realised that it's easier to do the left and right front teeth at the same time. 

We adjusted the code to divide the mouth into six sections with 20 seconds spent on each. This new approach makes sure that the front teeth get their share of the brushing.

The LEDs are very bright so we've turned the brightness right down. It's still plenty bright enough to see and avoids dazzling the kids. 

This was a great bit of design thinking in action and helped the kids to see that you don't always get things right first time, trying things out and then improving them got us to a to a better solution quickly.

Which Way Up?

You can decide with your kids which order it makes sense to brush their teeth in.

You'll need to think about which way up the Circuit Playground board will be so that you can program the correct LEDs. You can see the neopixel numbering here.

We ended up with the board upside down to accommodate the battery cable. This means that the left button becomes the right button!

Toothbrush Timer Code

I hid the trickier code in some helper functions so that the kids can understand the main loop code. The Circuit Playground is upside down so we start with pixels 6 and 7 to indicate brushing the top left part of the mouth. 

Main code:

#include <Adafruit_CircuitPlayground.h>
#include <Wire.h>
#include <SPI.h>

void setup() {
  CircuitPlayground.setBrightness(10); // Make sure the LEDs aren't too dazzling

void loop() {

  if (CircuitPlayground.leftButton()) {

    CircuitPlayground.playTone(440, 100); 

    segment(6, 7); 
    segment(4, 5);
    segment(2, 3);
    segment(1, 2);
    segment(9, 10);
    segment(7, 8);

    setColor(0, 9, 0, 255, 0);
    CircuitPlayground.playTone(440, 100);
    CircuitPlayground.playTone(780, 100);
    CircuitPlayground.playTone(440, 100);


    setColor(0, 9, 0, 0, 0);


void segment(int start, int end) {

    flash(start, end, 0, 0, 255);
    setColor(start, end, 0, 255, 0);
    CircuitPlayground.playTone(440, 100);

Helper functions:

void setColor(int start, int end, int r, int g, int b) {
  for (uint16_t i = start; i < end + 1; i++) {
    CircuitPlayground.setPixelColor(i % 10, r, g, b);

void flash(int start, int end, int r, int g, int b) {

  for (int s = 0; s < 40; s++)
    for (uint16_t i = start; i < end + 1; i++) {
      CircuitPlayground.setPixelColor(i % 10, r, g, b);


    for (uint16_t i = start; i < end + 1; i++) {
      CircuitPlayground.setPixelColor(i % 10, 0, 0, 0);



Toothbrush Timer Lips

We thought it would be fun to add some lips to the Circuit Playground board once we had got the user experience right. I discussed the design with my kids and we created a paper version and then created a 2D drawing in Inkscape - you could cut this out in card (plus a glossy red vinyl sticker) with a craft cutter (I love my Silhouette Cameo!), you could laser cut the lips from red acrylic, or you could extrude the design and 3D print it. We went for a 3D printed approach this time. 

We just attached the lips with mini red cable ties so that we can use the Circuit Playground board in other projects in future if we want to. (Don't tighten them too much if you want to be able to attach a USB cable.)

Alternatively you could print a photo of your child with their mouth open and use that to make a frame, or you could get them to draw a cool frame on a card template.

You can find the stl file for 3D printing and the svg file for Laser cutting or Craft cutting on Thingiverse:


For testing we just powered the Circuit Playground via USB from a laptop so we could adjust the code. 

Once we were happy with the way things were working we switched to a AAA battery pack.

The Circuit Playground is attached to the battery box using a magnetic badge pin, the rear of the badge is held in place with a velcro cable tie which also keeps the battery cables neat.

If you do this, attach the badge pin vertically, it seemed logical to me to attach it horizontally (the buttons are named left and right in the API) but it's actually a bit too long so it could cause problems if you wanted to use the middle pads. A bit of insulating tape would fix this, but it would be better to place it vertically.

Touch Switch?

We did experiment with using a touch switch with the Circuit Playground's capacitive touch capability. That works really well when the board is powered via USB but not with the battery pack. We'll save capacitative touch for another project!

Using the Toothbrush Timer

We placed the toothbrush timer just outside the bathroom that the boys use to clean their teeth so that they can look at it while brushing. It's been a big success.

Here's a sped up version of the toothbrush timer in action:

And here's a real-time version that you could just play instead of building your own toothbrush timer (building your own is more fun though!)

More from Tech Age Kids:


Post a Comment