7. Case 06: The Water Drinking Reminder#

7.1. Introduction#


  • Water is necessary for us and we can not live without water; water can regulate the circulation in the body, maintain the normal functions of the organs, and keep the body’s metabolic process smooth; water is an important component of human cells and liquids, if there is water shortage, the secretion of digestive juice decreases and appetite decreases; water plays an important role in body temperature regulation, if the outside temperature is high, it will evaporate water in the body to dissipate heat. Thus, we can make a device that reminds people to drink water regularly.

7.2. Function#


  • At regular intervals, program to turn on the buzzer for reminding of drinking water, the water valve could be opened by pressing the buttons on the micro:bit, and program to turn off the valve after a few seconds.

7.4. Picture#


../../_images/microbit-Smart-Health-Kit-case-01-02.png

7.5. Hardware Connection#


Connect the servo to P1 port on sensor:bit.

../../_images/microbit-Smart-Health-Kit-case-06-03.png

7.6. Software Programming#


Click “Advanced” in the MakeCode to see more choices.

../../_images/microbit-Smart-Health-Kit-case-01-04.png

For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “servo” in the dialogue box to download it.

../../_images/microbit-Smart-Health-Kit-case-01-06.png

Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.

7.7. Program#


Judge if “i” is true in forever block, if yes, judge if the result caculated by running time dividing 60000 is 0, if yes, set “i” in false.

../../_images/microbit-Smart-Health-Kit-case-06-07.png

If “i” is false, program to show icon and start palying the buzzer.

../../_images/microbit-Smart-Health-Kit-case-06-08.png

While button A being pressed, program to set the variable “i” in true and program to drive the servo.

../../_images/microbit-Smart-Health-Kit-case-06-09.png

Link: https://makecode.microbit.org/_PH4YUi598FXc

7.8. Result#


  • Program to play the buzzer for reminding of drinking water every minute, and program to control the water valve through the buttons on the micro:bit and shut the valve for some time.