56. Case 52: Smart Sweeper#

56.1. Introduction#

When we are doing housework or volunteering, floor cleaning may be the activity to be performed. With the development of our technology, we can make sweeping robots that can automatically clean the floor of a room and can initially replace our work. In this lesson, let’s initially make a simple sweeping robot that we can let the machine do our chores for us during our break. So let’s start.


Materials Required#

Nezha expansion board × 1

micro:bit V2 × 1

Ultrasonic sensors× 1

Line tracking sensor × 1

Line tracking map × 1

RJ11 cable × 1

Bricks × n

Note: If you want all of the above components, you may purchase the Nezha 48 IN 1 Inventor’s Kit.

Assembly Steps#

Component Details


Build it as the assembly steps suggest:
















56.2. Connection Diagram#

Connect two motors to M1 and M4, ultrasonic sensor to J2, and the line tracking sensor to J1 interface as the picture suggests.


56.3. MakeCode Programming#

Step 1#

Click “Advanced” in the MakeCode drawer to see more choices.


For programming the servo, we need to add a package. Click “Extensions” at the bottom of the drawer and search with “nezha” to download it.


For programming the PIR sensor, we need to add a package. Search with “PlanetX” in the dialogue box and click 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.



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

You may also download it directly:


As you can see, when the sweeping robot will stop when it hits an obstacle, the obstacle will leave and start cleaning again.