Skip to main content

Case 10: The Farm Protection Devices

In order to protect the farmlands from people to get in, we can set a farmland protection device.

Materials Requested

TOOCA L1 Laser Engraver

Smart Agriculture Kit

3mm Plywood

Relevant Parameters

ModelTOOCA L1 Laser Engraver
Material of consumablesBasswood board
Times required to be engraved/cut3

Note: This case takes a 2.8mm basswood board as an example. If you need to use different thicknesses or use different materials, please modify the drawing by yourself and refer to the Recommended parameter modify the parameters of the software.

Farm protection devices.dxf

Hardware Connection

Connect the Sonar:bit to P1, the PIR sensor to P2 on IoT: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 "iot-environment-kit" 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.


Set the ultrasonic sensor to connect to P1, measure the distance in cm, and save the return value to the variable "ultrasonic_distance", set the PIR sensor to connect to P2, and save the return value to the variable "IR".

Judge whether the value of variable "ultrasonic_distance" is within the threshold, if so, judge whether the return value of variable "IR" is 1, if the return value of variable "IR" is 1, then set the LED matrix to display the icon and the buzzer to sound the alarm otherwise turn off the light.

If the value of the variable "ultrasonic_distance" is not within the threshold, set to display the icon as we progrommed.



When someone approaches the farmland, the farmland protection device will display the icon and sound an alarm to warn others to stay away.

Effect Show