Projects / Brushing timer

Brushing timer

Beginner2.2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO

    Wire the sensor

    VCC to 5V, GND, SDA to A4, SCL to A5.

  2. NANO

    Wire the display

    VCC, GND, SDA to A4, SCL to A5 on the same bus.

  3. NANO

    Wire the buzzer

    Plus to D8, minus to GND.

  4. NANO

    Upload the sketch

    The display shows 2:00 and Paused.

  5. NANO

    Shake the sensor gently

    The state changes to Brushing and the time counts down.

  6. NANO

    Stop moving

    The clock pauses.

  7. NANO

    Tape the sensor in a bag to the dry end of a handle

    Test it dry on the bench first, away from water.

In short

How do you build a brushing timer?

An MPU6050 on the handle senses the brushing motion, and a Nano counts two minutes only while you are moving, with a beep every thirty seconds to change area. The sensor stays dry and out of the mouth. It is a timer, not a dental or medical device. You need Arduino Nano, MPU6050 IMU, SSD1306 OLED Display, Passive buzzer, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 130 minutes.

Level
Beginner
Time
About 130 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MPU6050 VCCNano 5VPower (a GY-521 style module has a regulator, check yours accepts 5 V)
MPU6050 GNDNano GNDCommon ground
MPU6050 SDA and SCLNano A4 and A5I2C, address 0x68 with AD0 low
OLED VCCNano 5VPower (check your OLED accepts 5 V, otherwise use 3V3)
OLED GNDNano GNDCommon ground
OLED SDA and SCLNano A4 and A5I2C, address 0x3C
Passive buzzer plusNano D8Beep (minus to GND)

Code

The MPU6050 module measures acceleration. The sketch reads it about fifty times a second and works out how much the total acceleration changes from one sample to the next, smooths that number, and treats a steady wobble as brushing. Time counts up only while the handle is moving, so pausing to rinse stops the clock. Every thirty seconds a short beep tells you to change to the next area of the mouth, and after two minutes of real brushing a longer beep sounds and the display says done. The sensitivity is set by MOVE_LEVEL, so raise or lower it until your own brushing counts and standing still does not. Safety: this uses low voltage but water and mouths do not mix with electronics. Keep the board and wires dry and out of the mouth, fix the sensor on the dry top end of the handle in a sealed bag, and power it from a USB power bank, not from a charger plugged into the wall while you brush. This is a timer for habit only. It is not a dental or medical device, and your dentist's advice comes first.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);

const uint8_t MPU = 0x68;
const uint8_t BUZZER = 8;
const unsigned long GOAL_S = 120;        // two minutes of brushing
const unsigned long CHANGE_S = 30;       // beep every thirty seconds
const float MOVE_LEVEL = 0.04;           // g of change between samples that counts as brushing

float lastMag = 1.0;
float motion = 0;                        // smoothed change in acceleration
unsigned long brushedS = 0;
unsigned long lastTick = 0;
bool done = false;

float readMagnitude() {
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);                      // first accelerometer register
  Wire.endTransmission(false);
  Wire.requestFrom(MPU, (uint8_t)6);
  int16_t ax = (Wire.read() << 8) | Wire.read();
  int16_t ay = (Wire.read() << 8) | Wire.read();
  int16_t az = (Wire.read() << 8) | Wire.read();
  float gx = ax / 16384.0, gy = ay / 16384.0, gz = az / 16384.0;   // default +-2 g range
  return sqrt(gx * gx + gy * gy + gz * gz);
}

void draw(bool moving) {
  oled.clearDisplay();
  oled.setTextColor(SSD1306_WHITE);
  oled.setTextSize(1);
  oled.setCursor(0, 0);
  oled.print(done ? "Done, well brushed" : (moving ? "Brushing" : "Paused"));
  oled.setTextSize(3);
  oled.setCursor(0, 20);
  unsigned long left = (brushedS >= GOAL_S) ? 0 : GOAL_S - brushedS;
  oled.print(left / 60);
  oled.print(":");
  if (left % 60 < 10) oled.print("0");
  oled.print(left % 60);
  oled.setTextSize(1);
  oled.setCursor(0, 54);
  oled.print("Area ");
  oled.print(min((unsigned long)4, brushedS / CHANGE_S + 1));
  oled.print(" of 4");
  oled.display();
}

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);                      // wake the sensor from sleep
  Wire.write(0);
  Wire.endTransmission();
  pinMode(BUZZER, OUTPUT);
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) {} }
  lastMag = readMagnitude();
  draw(false);
}

void loop() {
  float mag = readMagnitude();
  motion = 0.8 * motion + 0.2 * fabs(mag - lastMag);
  lastMag = mag;
  bool moving = motion > MOVE_LEVEL;

  if (!done && millis() - lastTick >= 1000) {
    lastTick = millis();
    if (moving) {
      brushedS++;
      if (brushedS >= GOAL_S) {
        done = true;
        tone(BUZZER, 1319, 800);
      } else if (brushedS % CHANGE_S == 0) {
        tone(BUZZER, 988, 250);
      }
    }
    draw(moving);
  }
  delay(20);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Sensor still on the tablePaused, 2:00
Gentle shaking for 30 secondsA beep and Area 2
Stop for ten secondsClock paused
Brush motion for two minutes in totalLong beep and Done
Slow tilts onlyNot counted as brushing

If it does not work

Always Brushing

Raise MOVE_LEVEL or check the module is held still.

Never Brushing

Lower MOVE_LEVEL, or check the I2C wires and the 0x68 address.

Display blank

Check the OLED address 0x3C and wires.

Sensor not found

Make sure AD0 is low and the module is powered.

Beeps too quiet

Use a passive buzzer on D8 and keep it near.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the brushing timer?

Arduino Nano, MPU6050 IMU, SSD1306 OLED Display, Passive buzzer, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the brushing timer take to build?

About 130 minutes for a beginner maker, in 7 steps.

How do I know the brushing timer works?

Sensor still on the table: Paused, 2:00. Gentle shaking for 30 seconds: A beep and Area 2. Stop for ten seconds: Clock paused.

Always Brushing: what should I check?

Raise MOVE_LEVEL or check the module is held still.

Never Brushing: what should I check?

Lower MOVE_LEVEL, or check the I2C wires and the 0x68 address.

Display blank: what should I check?

Check the OLED address 0x3C and wires.

Sensor not found: what should I check?

Make sure AD0 is low and the module is powered.