|Buy from USA||Buy from UK||Buy from DE||Buy from IT||Buy from FR||Buy from ES||ここでご購入を！|
In this project, we will use a PIR motion sensor to detect human movement, once an intruder’s motions is detected, then Pico will trig a buzzer alarm. This is a typical application used in many home security system.
In above circuit graph, you can see that:
PIR sensor VCC pin connected to VBUS(5V)
PIR sensor GND pin connected to GND
PIR sensor OUT pin connected to GP16
buzzer I/O pin connected to GP15
You can download lesson6 python code from https://osoyoo.com/driver/pico/lesson6/pico-lesson6.py
from machine import Pin #import Pin library import time # import time library buzzer = Pin(15, Pin.OUT,Pin.PULL_UP) #set GP29 as digital output pin for buzzer pir = Pin(16, Pin.IN,Pin.PULL_DOWN) # set GP16 as digital input pin for PIR motion sensor while True: if pir.value(): #when PIR detects motion print("Intruder is detected!") buzzer.low() # make buzzer alarm else: buzzer.high() #close buzzer alarm print("No Intruder!")
Step 1: Connect Pico board to one of USB ports in your PC
Step 2: If you haven’t installed Thonny Software or don’t know how to use Thonny IDE, please read lesson 1
Step 3: Now open the Thonny Python IDE, click Run to select MicroPython for Rapsberry Pi Pico as Interpreter :
Also please select the COM port which your Pico board is connected :
After that, click OK to save the setting.
Step 4: Now copy the python code to Thonny window as following:
select Raspberry Pi Pico as destination.
Step 6：Name the file as pico-lesson6.py, then click OK
Step 7: Click the little ► button again to run the Python code.
Now you put your hand close to PIR motion sensor, Buzzer will alarm and Shell will show “Intruder is detected”.
Now you remove your hand from PIR motion sensor, Buzzer will stop alarm and Shell will show ” No Intruder”.
After the operation is complete, press Ctrl+C to end the command.
|1||Raspberry Pi Pico Board||https://osoyoo.store/products/raspberry-pi-pico-flexible-microcontroller-board-based-on-the-raspberry-pi-rp2040-dual-core-arm-cortex-m0-processor-1-pc?variant=39875307864175|
|3||Infrared Sensor Module||https://osoyoo.store/products/hc-sr501-pir-motion-sensor-for-arduino?variant=31957812838511|
|4||RFID Module and card||https://osoyoo.store/products/osoyoo-rfid-module?variant=31970646130799|
|5||Push Buttons and Hats||https://osoyoo.store/products/push-button-and-hats-5pcs?variant=39879253131375|
|6||LED(6 x White, 6 x Red, 6 x Yellow, 6x Green)||https://osoyoo.store/products/led-packs-for-arduino?variant=31957816442991|
|8||Piezo Buzzer Module||https://osoyoo.store/products/piezo-buzzer-module-1pcs?variant=39879251656815|
|9||I2C LCD Display(16×2)||https://osoyoo.store/products/i2c-lcd1602-display?variant=39875437101167|
|11||Solderless Prototype Breadboard||https://osoyoo.store/products/solderless-prototype-breadboard-1pcs?variant=39879255457903|
|12||Potentionmeter (10K adjustable resistor)||https://osoyoo.store/products/potentionmeter-10k-adjustable-resistor-3pcs?variant=39879281016943|
|13||40Pin M to M Jumper Wires||https://osoyoo.store/products/40pin-m-to-m-jumper-wires?variant=39879256539247|
|14||20Pin M to F Jumper wires 15cm||https://osoyoo.store/products/20pin-15cm-female-to-female-cable?variant=31930663305327|
DownLoad Url osoyoo.com