Introduction
In this Raspberry Pi Pico series tutorial, we will learn how to interface a PIR Motion Sensor with Raspberry Pi Pico. PIR sensor is a sensor that is used to detect the presence of an object by measuring the infrared radiation emitted by the object.
PIR sensors are used in many applications, including security systems, motion detectors, and automatic doors. PIR sensors can be used with Raspberry Pi Pico to detect the presence of people or objects.
Required Components
- Raspberry Pi PIco —>https://amzn.to/3LCIoWqÂ
- PIR Sensor —>https://amzn.to/3KxRlPK
- Jumper wire —>https://amzn.to/3LN8ohS
What is a PIR Motion Sensor?
PIR sensors are sensitive to infrared radiation, which is emitted by warm objects. When a PIR sensor detects an infrared ray, it produces a signal that can be used to trigger an event, such as turning on a light. In this tutorial, we’ll show you how to use a PIR sensor with Raspberry Pi Pico.
PIR sensors are available in many varieties of shapes and sizes in the market. In this tutorial we use The HC SR501Â PIR Motion Sensor, This sensor is a good choice for this tutorial because it’s easy to use and it’s already
The PIR sensor has three pins: power, ground, and signal.
Circuit Diagram of PIR Motion Sensor with Raspberry Pi Pico
The circuit diagram is very easy to how a Raspberry Pi Pico and PIR motion sensor can be used together. The PIR sensor is used to detect movement, and the Raspberry pi pico is used to control the PIR sensor and turn it on or off the buzzer Or alarm.
Micropython Code: PIR Motion Sensor with Raspberry Pi Pico
Open Thonny IDE and paste the following code: Check also How to Setup a Raspberry Pi Pico and Code with Thonny IDE
main.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from machine import Pin import time sensor_pir = machine.Pin(28, machine.Pin.IN) led = machine.Pin(15, machine.Pin.OUT) def pir_handler(pin): print("Motion detected!") for i in range(50): led.toggle() time.sleep_ms(100) sensor_pir.irq(trigger=machine.Pin.IRQ_RISING, handler=pir_handler) while True: led.toggle() time.sleep(5) |
Conclusion
After the Upload code, You will see that the Buzzer remains OFF when no motion is detected and when the PIR sensor detects motion, Buzzer is ON.
Read Similar Articles:
-
- Getting Started Raspberry Pi Pico – Pinout, Specs – Beginner Guide
- Interfacing PIR Motion Sensor with Raspberry Pi Pico
- Raspberry Pi Pico Home Automation System
- Interface Servo Motor With Raspberry Pi Pico
- Interface 0.96″ OLED Display with Raspberry Pi Pico
- Raspberry Pi Pico Weather Station Using Dht11 Sensor
- Interface 16*2 LCD Display With Raspberry Pi Pico
6 Comments
Pingback: Interface Servo Motor With Raspberry Pi Pico Using Python- Explain
Pingback: Interface 0.96" OLED Display With Raspberry Pi Pico -Explain
Pingback: Raspberry PI Soil Moisture Sensor Tutorial With Python Script 1
Pingback: Getting Started Raspberry Pi Pico Pinout, Specs -Tutorials 1
Pingback: How To Interface Raspberry Pi With Ultrasonic Sensor Tutorial
Pingback: Raspberry Pi Pico ADC | Read Analog Values With Micropython