User Tools

Site Tools


burim:project:pi:motion-sensor
licht gpio26
sensor gpio16

http://www.netzmafia.de/skripten/hardware/RasPi/Projekt-PIR/index.html

root@pi3plus:/home/pi/python# cat pir_v1.2.py
import RPi.GPIO as GPIO
import time

SENSOR_PIN = 12
LED = 21

GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN, GPIO.IN)
GPIO.setwarnings(False)
GPIO.setup(LED, GPIO.OUT)


def mein_callback(channel):
    # Hier kann alternativ eine Anwendung/Befehl etc. gestartet werden.
    print('Es gab eine Bewegung!')
    GPIO.output(LED, GPIO.HIGH)

try:
    GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING, callback=mein_callback)
    while True:
        time.sleep(15)
        GPIO.output(LED, GPIO.LOW)
except KeyboardInterrupt:
    print "Beende..."
GPIO.cleanup()
burim/project/pi/motion-sensor.txt · Last modified: 2018/10/28 12:22 by burim

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki