Brush Your Teeth!

by ClemRz in Circuits > Arduino

7285 Views, 74 Favorites, 0 Comments

Brush Your Teeth!

P1310006.JPG
P1310007.JPG
P1300963.JPG

My 5yo son dislikes, as many 5yo kids, brushing his teeth...

I found out that the biggest impediment is actually not the act of brushing his teeth per se, but the time spent doing it.

I did an experiment with my cellphone's countdown to let him track the time he spends on each teeth group (lower-left, lower-right, upper-left, upper-right, front). What I learned from this experiment is that it makes this task much easier for him. After that, he actually asked for it and brushed his teeth with no complains at all!

So I thought: I'll make a small countdown artefact that he could use by himself so he gets more independent and hopefully brush his teeth more often and with more care.

I know there are some other DIY projects and commercial products that does exactly this, but I wanted to tinker a bit and to create my own design.

Here are the criterias for my design:

  • As compact as possible
  • Display 2 digits numbers and signs
  • Emit a sound at the beginning of each teeth group
  • Rechargeable
  • As simple to use as possible

In this Ible I'll show you how I designed and created it.

Enjoy!

Supplies

  • 1 x Arduino pro mini
  • 2 x 7 segments display
  • 1 x push button
  • 1 x autotransformer
  • 1 x piezo buzzer
  • 2 x 470Ω resistors
  • 1 x li-ion charger/booster module
  • 1 x 17360 li-ion battery (in the picture you'll see a 18650 and it's holder but to make it more compact I later changed my mind)
  • a perfboard
  • some wires
  • some double sided foam tape
  • an enclosure (I made a wooden one, could be 3D printed)
  • 4 x rubber feet
  • some CI glue

Solder the Components

schematics.png
P1300966.JPG
P1300968.JPG
P1300967.JPG
P1300964.JPG
P1300965.JPG
P1300970.JPG
P1300971.JPG
P1300972.JPG
P1300975.JPG
P1300976.JPG
P1300977.JPG
P1300978.JPG
P1300979.JPG
P1300980.JPG

I had previously created a proof of concept with an Arduino Uno and a protoboard so I could write the code and decide what components to use. I'll not share that part of the process since it's very boring and wouldn't bring much to this ible.

Schematics

The schematics are available in Tinkercad: https://www.tinkercad.com/things/77jwLqAcCNo-migh... it is not complete because some components are not available in the library and the code is not runnable as is because it needs a specific library. Nevertheless it shows quite accurately the overall idea behind the simple circuitry.

In the following descriptions I never state what pin is connected to what intentionally. I think the pin assignation will depend on how you lay your components out. In the next step you will easily find where to set the pin assignation by editing the Arduino code.

Layout

I first laid on the perfboard where I wanted the 7 segments digits to be regarding to the position of the Arduino. It happens that this particular perfboard is very handy: it is designed pretty much like a proto board with convenient connections plus it's double sided printed. If I set the segments on one side and the Arduino on the other, I can have most of the digits pins to match with I/O pins and I get a very compact layout!

If you have a way to (make) print your own boards then maybe the best thing is to design your own.

Digits

I found out that the easiest way to display two-digits numbers and symbols is by using 7 segments LED digits.

How 7 segments digits work in relation with the Arduino

A 7 segments digit has 10 pins: one for each segments, one for the dot/period and two for the common anode/cathode (called A/K later on) (internally connected together). In order to reduce the number of pins used by the segments with the Arduino, all the segments and dot pins are connected together and to a I/O pin, which sum 8 I/O pins used. Then, one of the A/K pin of each segment is connected to another I/O pin. In the case of a 2 segments display this sums 10 I/O pins usage (7 segments + 1 dot + 2 digits x 1 A/K = 10).

How can it display different things on every digits then? The library that drives those I/O pins leverages that on the retinal persistence of the human eye. It turns on the A/K pin of the desired digit and off all the rest, setting the segments properly and then quickly alternating with the other digits using their own A/K pins. The eye won't "see" the blink since it's at a high frequency.

Soldering

I soldered the digits first and the connections between them, then I soldered the Arduino on the other face. You'll notice it is important to perform all the digits interconnections before soldering the Arduino because it will prevent you to access the back of the digits once in place.

Chose a proper current-limiting resistance

The datasheet for my displays indicate a forward current of 8mA and a forward voltage of 1.7V. Since the Arduino I'm using works with 5V I need to drop 5 - 1.7 = 3.3V at 8mA. Applying Ohm's law: r = 3.3 / 0.008 = 412.5Ω
The closest resistors I have are 330Ω and 470Ω. To be on the safe side I chose the 470Ω resistor to limit the current through each diodes of the display. The brightness of the display is inversely proportional to the value of that resistor so it is important to use the same value for each digits.

Piezo buzzer

How to simply emit a sound with an Arduino and keep it compact at the same time? The best way I found is using one of those slim piezo buzzers one can found in door alarms for instance.

We need a way to amplify the sound emitted by that buzzer though because if we connect it directly to the Arduino it is hard to hear anything from it.
We will amplify it by those two means:

  • with an autotransformer which will elevate the voltage, the higher it is the louder will be the piezo
  • with a passive acoustic amplifier, a box basically, like a guitar: if you attach the piezo to a cardboard for instance you'll immediately notice a louder sound

An autotransformer can be found in that same door alarm, it's a small cylinder with usually 3 pins. One pin goes to the Arduino I/O pin, one to the piezo and the last one is connected to both the Arduino GND and the other piezo wire. It's hard to know what pin is which so try different configurations until you hear the loudest sound coming out of the piezo.

Power

Disclaimer: I know it can be a bad idea to solder directly on a li-ion cell, don't do it if you are not comfortable with that.

I chose to power the circuit with a small li-ion cell, this imply the usage of a module to protect it, to charge it and to boost the voltage to 5V (li-ion cells usually produce around 3.6V). I took that module from a cheap power bank and unsoldered the cumbersome USB-A connector.

The module indicates where the cell needs to be connected. Looking online for the pinout of the USB-A female connector I could connect the 5VCC wires from the module to the arduino GND and VCC pins. If you ever decided to power the Arduino with more than 5V then you will want to feed that through the RAW pin so you can let the on-board voltage regulator lower it to the 5V required by the ATMega.

Since it is a rechargeable power source I needed a way to know when it is discharged. For that, I connected the positive end of the cell to a analog pin of the Arduino. During the setup sequence I'll read that voltage and convert it to a readable way to evaluate the charge level. I wrote a gist about the li-ion capacity formula. Later I'll explain how I display it.

Button

We need a way to start the countdown and for that a on/off rocker switch would have been fine. I chose to use a momentary push button connected between GND and RESET pins. At the end of the whole countdown cycle, the Arduino goes to a deep-sleep state and can be woken-up either by powering it off then on, or setting the RESET pin to low, which is convenient. That push button allows me to "turn on" the countdown and to reset it whenever I want. I cannot turn the countdown of when it's started though, but it's not a big deal I think.

Edit and Upload the Code

Screen Shot 2020-06-15 at 16.34.01.png

You will find the code attached. It uses a library named SevSeg that you can either install using the IDE's libraries manager or download at https://github.com/DeanIsMe/SevSeg.

There are several changes you may want to bring before you upload it:

Countdown

For each teeth group, a countdown is displayed. I set it to 20 seconds for each group. There are 5 groups and some pauses for symbol display in between (see below) so the total time spent brushing the teeth should be around 2 minutes. I've heard this is the recommended timing.

If you want to modify the timer, look at line 14.

Pin assignments

  • if you are using common-cathode displays, change line 84 to "COMMON_CATHODE"
  • for the segments pins, change line 82 (currently set to 4 to 11)
  • for the A/K pins, change line 80 (currently set to 2 and 3)
  • for the voltage sensor, change the pin line 23 (currently set to A0)
  • for the buzzer, change the pin line 19 (currently set to 12)

Sounds

I defined some musical notes with their approximate frequency from line 36 to 41, if you feel you want to play different tones you may want to add more to that list.

It pays 2 different tones:

  • a kind of chirp at the beginning of each teeth group, line 206
  • a "party" tone at the very end (kind of reward), line 201

You can change those tones, the lists contain an alternance of musical note and duration of the note, be creative!

Animation

At the beginning of each teeth group there is a display symbolizing the group in question. The five groups symbols are defined from line 71 to 74. You can edit this if you'd like.

At the very end of the sequence, those symbols are alternated to form a sort of animation.

Battery level indicator

At the very beginning of the sequence, the battery level is indicated as a "bar" display show up during 3 seconds. Each digit can display three horizontal bars. When all 6 bars are displayed it means that the battery is full. The bars wont lit from top to bottom and left to right with the battery level decreasing. You could change that and display a number representing the remaining percentage of energy if you'd like, the code is located line 100.

Create an Enclosure

P1300988.JPG
P1300987.JPG
P1300991.JPG
P1300992.JPG

You will find attached a Sketchup model of the one I designed.

It will probably not fit your needs since it tightly depends on the compactness and the size of your circuit/components. Tweak it as you need :)

I used 3/16" birch plywood I think, and a 1/2" round dowel for the button cap.

You'll notice that a carved the back of the box where the piezo buzzer will be attached, this is where I perform the passive acoustic amplification.

Fit the Components in the Enclosure

P1300996.JPG
P1300981.JPG
P1300982.JPG
P1300989.JPG
P1300990.JPG
P1300994.JPG
P1300998.JPG
P1310003.JPG
P1300999.JPG
P1300993.JPG
P1300995.JPG
P1300997.JPG
P1310002.JPG
P1310007.JPG

I used some double sided foam tape to keep the battery, the charger/booster module and the piezo buzzer in place. I also used some of it as a spacer between the perfboard and the plywood or else the display would protrude in a not-so-beautiful fashion.

I sticked the push button with CI glue but it wasn't enough to withstand the pressure when actuating it so I used a small diameter dowel to keep it in place (see the picture).

I used CI glue as well to stick the piezo buzzer on the back plate before I closed it up.

My recommendation: test that everything works once in a while during fitting, I had to reopen and isolate some short-circuiting areas, several times!

Add some rubber feets to the bottom, it gives a professional look ;)

Conclusion

P1310004.JPG
P1310005.JPG

You may notice that the digits are upside-down, this is a mistake I made since the layed out the components. I solved that issue by moving the pin assignment around, it's no big deal since I'm not using the dot/period.

Anyway, this project was really fun to make and my kid loves it!

Don't hesitate to post your comments and suggestions!

Thank you for reading.