User Manual
25 26
Project 11 :  Guardians of The Secrets in Your Room
Diculty Level
Part List
Description
11. Guardians of The Secrets 
in Your Room
This demo will help guard your room. If 
anyone enters your room, the red LED will 
flash and the speaker will play an alarm. It is 
similar to the previous demo, except that this 
demo uses the ultrasonic sensor. If you have 
tried the demo, “smart guard”, this one 
should be a piece of cake.
 Note: This project requires high input 
voltage, please use the Grove Shield for 
micro:bit to power the circuit.
1x Grove - Speaker
1x Grove - Ultrasonic Ranger
1x Grove - Red LED
1x Grove Shield for micro:bit
1x micro:bit
1
2
3
4
5
Steps
1. Add basic block forever, then add variable block set item to and 
grove block Ultrasonic Sensor (in cm) at P1, Rename “item” to 
“distance”
5. Hardware connection: connect the Grove modules as 
instructed in page 25.
6. Click Download to transfer your code in your micro:bit!
7. Move your hand up and down in front of the ultrasonic 
sensor and see if your guardian works well.
Try to use this creation to protect your room.
3. For ‘then’, add loop block repeat 4 times, the add a pin block 
digital write pin P2 to 1 and a music block play tone High C for 1 
beat. Add block pause (ms) (100), then add a pin block digital write 
pin P2 to 0 and a block pause (ms) (100) after it.
4 Add the last basic block pause (ms) (100).
1
1
3
3
4
4
2
2
4
2
1
3
5
P0/P14
P1/P15
P2/P16
 Add logic block “if…then…”.For condition “if”, add logic block 
0 ≥ 0, replace the first “0”with variable block distance, change 
another “0”to “60”. 










