1. Case 01: Touch-free Hands Washing Device¶
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.
Detect if there is anyone approaching with the PIR sensor, if yes, program to open the water valve.
1.5. Hardware Connection¶
Connect the PIR sensor to P1 and the servo to P2 on sensor:bit.
1.6. 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.
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.
If the PIR sensor detects someone, program to open the water valve; or program to close it.