Lockdown Learning: A tooth-brushing timer

On Monday we had our first dentist appointment for over a year! No major issues (phew…) but the kids received a reminder about the importance of brushing teeth for 2 minutes every time. Faced with the prospect of having my phone waved around over a tiled floor and a toilet bowl twice a day, I suggested we should make a Crumble timer.

This turned out to be a really nice project. Even with just the components in our Starter Kit there is scope for different approaches (sounds/flashing lights/colour sequences) and it was a great opportunity to learn/recap how to use inputs and outputs.

My 8-year-old decided on the simplest approach: wait for 2 minutes and then sound a buzzer. While we were connecting the components, he asked if we could just connect “+” on the buzzer to “+”  on the battery box and use the battery box switch to turn the buzzer on and off. This is an excellent question because, of course, we can do that: the buzzer and battery box (with its built-in switch) can be connected in a simple circuit. When the switch is closed the electricity will flow and the buzzer will sound. 

Buzzer, battery and switch connected in a simple circuit.


Inputs and Outputs

This brings us nicely to a fundamental question: why do we use the Crumble at all? The reason is to give us control. We only want the buzzer to sound after 2 minutes has elapsed.

The chip (microcontroller) on the Crumble (or in your central-heating system/washing machine) takes information (input) from the user and runs a set of instructions (an algorithm) in order to determine which processes to run and what to ouput.

A clever feature of the Crumble is that pads A, B, C and D can function either as inputs or outputs. The Crumble will either set them (as outputs) or begin to monitor them (for input) depending on which blocks (processes) are used in the program:

We instruct the Crumble to monitor inputs using commands like:

When we connect a switch between “+” on the battery box and (e.g.) pad “A” on the Crumble we are not using it to turn the Crumble on and off. Instead, when the switch is pressed, electricity flows to pad A and the Crumble detects this as an input. If the switch is closed, A is “Hi”; if it is open, A is “Lo”.

We set outputs using these blocks:

When we connect the “+” pad of the buzzer to (e.g.) pad “C” on the Crumble, the Crumble then controls whether electricity flows to output C and, hence, whether the buzzer will sound. 

The wiring for the 8-year-old’s project is shown, below:

Wiring diagram for a simple timer with buzzer.

And here is the program that is sent to the Crumble:

Crumble program for a 2-minute timer

The Crumble waits until the switch is pressed (in this case, it is connected to “B”); waits for 2 minutes (quick bit of maths to convert this to seconds); then turns the buzzer on.

We had also thought about how you would use the timer in the bathroom. You could turn the buzzer off with the switch on the battery box but you shouldn’t do this with wet hands! Instead, we added the “wait 10 seconds” and “set C LO” blocks so the buzzer turns off after 10 seconds. The program then loops back to the start and the timer is ready for next time.

A coding challenge

Meanwhile, the 11-year-old was working on his own timer. (He found a Sparkle baton to use for his lights but the individual Sparkles from the starter kit can be used in a similar way.) He decided he wanted to see the time progressing so programmed each Sparkle to change from red to green, in turn, over the 2 minute period. At the end of the 2 minutes a buzzer (connected to “B”) pulses on and off for a few seconds.

This is the first program he wrote:

Crumble program for a 2-minute timer using a Sparkle baton and buzzer.

It works as required but it contains a lot of repeated lines. This suggests it is not the most efficient way to write the code. I set him a challenge to re-write his program using a loop and a variable:

Program with the same function as above, but coded more efficiently.

The resulting program does exactly the same but it is a lot shorter and would also be much quicker to adapt if he decided he wanted to change the colours or the time interval. Note, also, that it only takes up half the space in the Crumble’s memory. Writing efficient code is an important skill!

Design for purpose

Now we have the Crumble connected and programmed, we can think about other elements of design. We added a loop to the first program so we wouldn’t have to manually turn the buzzer off but there is always a risk, in a bathroom, that the components could get splashed. How could we mitigate this risk? Can we enclose the timer but still be able to press the button to activate it? Or is there a different type of input we could use?

We do, in fact, have several inputs that can be activated without touching them: the light sensor (included in the starter kit); the ultrasonic distance sensor; a tilt switch and a reed (magnetic) switch.

My version of the toothbrush timer, therefore, uses all the starter kit components inside a Tupperware box. Instead of being triggered by the push-button switch, the light sensor is used at the bottom of the box. When the box is picked up, the Crumble detects the change in light level and starts the timer sequence.

Wiring diagram for the light-sensor activated timer

Crumble program for the light-sensor activated timer

I used modelling clay to hold the Sparkles and light sensor in place, facing outwards. For the light sensor, this also helps to block out the ambient light when the box is resting on a surface. We pick up the box to trigger the timer sequence.


The Sparkles turn red, amber then green, in turn. I have used a variable “time” to control how long the light sequence lasts. This is set at the top of the program so could easily be changed, if required. Once the 2 minutes have elapsed, the buzzer pulses. The Sparkles are then turned off and the program loops back to the beginning and waits for the trigger.


What other types of timers can you think of? Would they require any different design features? If you try this, or a similar project, we’d love to see it!

Comments are closed.