Create your own motion detector alarm, which you can use to monitor if anyone is entering or walking by a room.
Step 1: Components Required
Step 2: Video :
Step 3: Creating the Circuit
- Plug in the micro:bit into the micro:bit Prototyping Shield
- There are 3 pins coming off the PIR sensor and LED module ( S, +, -), Connect the positive (+) pin of both to the 3.3V pin of micro:bit Prototyping Shield using jumper cables.
- Similarly, connect the negative ( - ) pins of both to the ground (GND) of micro:bit Prototyping Shield
- Now, connect signal pin of PIR sensor to pin 0 (P0), signal pin of LED module to pin 2 (P2)
- The piezo buzzer should have a positive and a negative leg or wire. Connect the positive ( + ) leg or wire of the piezo buzzer to pin 1 (P1) on the micro:bit Prototyping Shield and the negative ( - ) leg or wire to ground (GND)
Step 4: Import the Code
- Plug in the micro:bit
- Navigate to microbit.co.uk/app
- Click on Let's Code. The Following window will appear in which you'll be provided with the languages you have to select one you want to code with
Click on Java Script and start Dragging and dropping.
The code is shown in the images below.
At last, Download the hex file and paste it on the connected microbit // Note : I've attached the hex file, You can directly download it and paste it on your microbit
Step 5: Test and Play
You can adapt it to suit your purposes.You can also adjust how long the buzzer for in response to the movement.
One more thing is that you can also change the image that your BBC micro:bit displays. Simply click on the show leds block and change it to whatever you like.