How to build a device of detecting the distance with a micro:bit

How to build a device of detecting the distance with a micro:bit

Purpose

The novel Coronavirus is still existing in the world and we need to make sure the social distance be kept in public areas such as in hospitals or banks. This device will warn people who do not keep enough distances to others.

Materails

micro:bit x 1

Wukong expansion board x 1

Sonar:bit x 1

3pin wire x 1

Rivets x 2

Bricks x N

Assembly steps

Install the bricks to Wukong board with the parts as the picture shows:

The connect sonar:bit with the rivets and the 3pin wire.

Hardware Connections

Connect sonar:bit to the P0 port on Wukong board.

Software programming

Go to MakeCode editor:(https://makecode.microbit.org/#editor)Add Wukong extension from the settings on the right upper conner.

Add the extension package of neopixel.

Coding

Initialize the RGB on the Wukong board in the on start brick.

Save the variable of the sonar bit as “i” in forever brick.

Judge if “I”is between 3~100, if yes, set the RGB as red; or set it in green.

Complete code

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

Completed! Now we can find a wire to have the device hung on our body to keep the social distance with others.

Result

It lights up in red if someone is within one meter away from you or it lights in green.