Invasion alarm is a device that alarms when detecting illegal invasion in a prevention area. It plays a pivotal role in security prevention, so it is widely applied to family, stores, warehouses and supermarkets. Thus, our life can be better protected from illegal invasion. Meanwhile, our personal and property safety can also be guaranteed.
In this experiment, we adopt PIR motion sensor, power amplifier and a white LED to form an invasion alarm. When someone is detected, the white LED flashes and the amplifier alarms.
Flow

Assembly

Required Parts


Step 1


Step 2


Step 3


Step 4


Step 5


Step 6


Step 7


Completed


Wiring Diagram

Test Code
Open KidsBlock and connect the board to your computer. Click File –> Load from your computer.

Choose D:\Code\1.Code_kidsuno to open 4.2Invasion alarm.sb3 file.

Click
to connect to port and then
.
Explanations

Conceive:
When the sensor detects a human motion (an invasion), the LED flashes and the amplifier alarms. If it detects nothing, LED will go off and the amplifier will not emit sound.

Build blocks:
-
Initialization: Set the pins of the PIR motion sensor, white LED module and the power amplifier.

-
Loop:
Read the power level of the board input from the PIR motion sensor.
Determine whether the power level is 1(indicates an invasion).
-
If yes, the LED flashes and the amplifier alarms.
-
If not, LED will go off and the amplifier will not emit sound.


Test Result

After uploading code, when the sensor detects a human motion (an invasion), the LED flashes and the amplifier alarms.


FAQ
Q: After uploading code, the LED and amplifier are no response when you put your palm in front of the sensor?
A: The PIR motion sensor detects only movement rather than objects.
Q: After uploading code, the LED lights up but the amplifier does not emit sound?
A: Rotate clockwise the potentiometer on the amplifier to turn up the sound volume.