I bought DSUN-PIR http://www.aitendo.com/product/10254
#!/usr/local/bin/python
-- coding: utf-8 --
from future import print_function
import RPi.GPIO as GPIO
import os
import time
SENSOR_PIN = 25
LED_PIN = 24
GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED_PIN, GPIO.OUT)
while True:
pin_status = GPIO.input(SENSOR_PIN)
print(pin_status)
GPIO.output(LED_PIN, pin_status)
time.sleep(1)
GPIO.cleanup()
If you set the LED to number 24, it will shine.
Seen from the front Left detection interval Right detection distance Like
Recommended Posts