Skip to main content

Case 01: Touch-free Hands Washing Device

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.

Function


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

Picture


Hardware Connection


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

Software Programming


Click "Advanced" in the MakeCode to see more choices.

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.

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.

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.

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.

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

Result


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