2. Case 01: Touch-free Hands Washing Device#

2.1. Introduction#


  • Maintaining clean and hygienic hands can prevent diseases from entering the mouth, thereby reducing the risk of intestinal infectious diseases such as diarrhea and respiratory infectious diseases such as pneumonia. After washing our hands, we need to close the water valve, which will cause pollution to our hands, thus, we can make a touch-free hand washing device.

2.2. Function#


  • Detect if there is anyone approaching with the PIR sensor, if yes, program to open the water valve.

2.4. Picture#


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

2.5. Hardware Connection#


Connect the PIR sensor to P1 and the servo to P2 on sensor:bit.

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

2.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 “smarthome” in the dialogue box to download it.

../../_images/microbit-Smart-Health-Kit-case-01-05.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.

2.7. Program#


Judge the detected motion of variable “IR”, if yes, set to show “√” and the servo to drive to 0° to open the water valve; or set to show “x” and to drive to 180° to close the water valve.

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

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

2.8. Result#


  • If the PIR sensor detects someone, program to open the water valve; or program to close it.