Programming and note
If/else:
In this case, when the value digital read from the PIR motion sensor is true(1), turn
on the buzzer and show an angry icon for 5 seconds, otherwise, clear the micro:bit’s matrix
LEDs and turn off the buzzer.
Clear screen:
This
clear screen
block will clear all the information displayed on
micro:bit’s matrix LEDs when it runs. Here, we clear matrix LEDs when PIR motion sensor
does not detect the movement of Infrared energy.
Download the program to micro:bit to see what happens.
Wave your hand in front of the PIR motion sensor, and you will see an angry
icon on the micro: bit matrix LED, and the buzzer will beep for 5 seconds. If
you stop any movement, the icon will no longer be displayed and the buzzer
will stop beeping.
Result
What does infrared energy mean? Can PIR motion sensor detect your pet's movement?
22