From Sketching with Hardware at LMU Wiki
Jump to navigation
Jump to search
|
|
(3 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
| = Description =
| | #REDIRECT [[Passive Infrared Sensor]] |
| A PIR Sensor can detect motion, it is also called motion sensor. It detect moveing people or animals. PIR stands for passive infrared. Here we use the SR602.
| |
| | |
| It has 3 connectors:
| |
| * - connected to GND
| |
| * + connected to 3.3V
| |
| * Out - digital output is 1 if motion is detected
| |
| | |
| [[File:Pir3.PNG|x300px]] | |
| | |
| = How to connect it electrically =
| |
| [[File:PIR-electro.PNG|x400px]]
| |
| | |
| = How to control it in MicroPython =
| |
| Reading the value and printing it to the console
| |
| <syntaxhighlight lang="python" line='line'>
| |
| #Example usage for ESP32
| |
| from machine import Pin
| |
| from time import sleep
| |
| # digital input on pin 26
| |
| pir = Pin(26, Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
| |
| | |
| while True:
| |
| pirVal = pir.value()
| |
| print(pirVal)
| |
| sleep(1)
| |
| </syntaxhighlight>
| |
| | |
| = Related Tutorial Videos =
| |
| <youtube>C0W-wI0qHIQ</youtube>
| |
| | |
| <youtube>dVE7R-Spf6M</youtube>
| |
Latest revision as of 09:46, 11 June 2024