mirror of
https://github.com/kevinveenbirkenbach/erinaco.git
synced 2024-11-23 14:31:04 +01:00
21 lines
434 B
Python
21 lines
434 B
Python
import RPi.GPIO as GPIO
|
|
import time
|
|
|
|
SENSOR_PIN = 19
|
|
|
|
GPIO.setmode(GPIO.BCM)
|
|
GPIO.setup(SENSOR_PIN, GPIO.IN)
|
|
|
|
def mein_callback(channel):
|
|
# Hier kann alternativ eine Anwendung/Befehl etc. gestartet werden.
|
|
print('Es gab eine Bewegung!')
|
|
|
|
try:
|
|
GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING,
|
|
callback=mein_callback)
|
|
while True:
|
|
time.sleep(1)
|
|
except KeyboardInterrupt:
|
|
print("Beende...")
|
|
GPIO.cleanup()
|