- Let’s make a self defense monitoring station.
- 1 x IOT:kit
What is self defense?
- You need to set a self defense device when your environmental monitor station is out of doors to prevent device damage and to warn people keep away from this device.
As below picture, let the ultrasonic module be connected to
Let the human infrared sensor module be connected to
Let the onboard buzzer be connected to
- Click on “Advanced” in the MakeCode Drawer to see more code sections.
- We need to add an extension for coding to the IOT. Click on the “Extension” at bottom of coding drawer, then Search for “IOT” and click on the IOT package to add it to your project. (As below picture)
Note：If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Project file menu.
Get value from
P1 and assignment it to
IR block uner
forever, to judge if
IR is equal to
IR parameter is equal to
1, get the ultrasonic returned value again and assignment to the
ultrasonic variable is lower than 30, play a
ba ding to warning.
If you don’t want to type these code by yourself, you can directly download the whole program from the link below: