How to make a guitar with a micro:bit ?

How to make a guitar with a micro:bit ?


To make a guitar with a micro:bit and an ultrasonic sound sensor.


micro:bit x 1

Nezha expansion board x 1

Sonar:bit x 1

RJ11 wire x 1

Bricks x N

Assembly steps

Build a device as the picture shows:

Hardware Connections

Connect the sonar:bit to J1 port on Nezha expansion board.

Software programming

Go to MakeCode editor:( Wukong extension from the settings on the right upper conner.

Search with Planet X in the dialogue box and add it to the package.


Drag “show icon” into the “on start” brick, save the detected value from the sonar:bit as “I” and judge if it’s between the setting ranges. If yes, set the buzzer to play the tones.

Code more with the slimar procedure and pause for 500ms.



Change the tones of the micro:bit guitar from adjusting the distances from the bricks board to sonar:bit.