Motion Detector

Uses

Passive Infrared Sensor (PIR Sensor), pins, speaker

Description

In this project, you will be creating a motion detector that will detect movements and create a sound on the speaker when there is movement. This is usually used for burglar or security alarms.

../../_images/security-alarm.jpg

A security alarm is a system designed to detect intrusion – unauthorized entry – into a building or other area. Security alarms are used in residential, commercial, industrial, and military properties for protection against burglary (theft) or property damage, as well as personal protection against intruders.

../../_images/motion-detector.jpg

You will be using a Passive Infrared Sensor (PIR sensor) that detects infrared (IR) light from objects. It will generate a signal when there is a movement detected by a person, or any warm bodies object. It usually has a lens to increase the area of detection since a PIR is a small device. Here is the diagram on how to connect the PIR to the microbit.

PIR will be utilizing the pin0 to send the signal to the microbit. If there is movement detected, it will send a high signal to pin1 to create a sound to the speaker.

Basic Task

  1. Read analog signal on pin0. The higher the reading (max is 1024), the higher the voltage. You might need to calibrate the value first, so you can use the print() command to print out the measurement to the REPL and try out with lights turned on and off.
  2. Compare measured value with your threshold value based on your calibration. This will determine if you need to turn off or on the LED.
  3. Send a high signal (.write_digital(1)) to pin1 to create a sound when there is movement, and a low signal if there is no movement.