Hallo,
ich möchte mittels GPIO 22, den ich mit einem Optokoppler auf 3,3V ziehe, ein Programm je nach Zustand an oder aus schalten.
Python
#!/usr/bin/python2
import sys
sys.path.append('/storage/lib')
import RPi.GPIO as GPIO
import subprocess
import time
import os
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def aus(channel):
print("aus")
def an(channel):
print("an")
GPIO.add_event_detect(22, GPIO.RISING, callback=an, bouncetime=100)
GPIO.add_event_detect(22, GPIO.FALLING, callback=aus, bouncetime=100)
while True:
time.sleep(1)
Alles anzeigen
nun funktioniert das Script nicht so wie ich mir das vorstellte.
Code
Kodi:~ # Traceback (most recent call last):
File "test.py", line 22, in <module>
GPIO.add_event_detect(22, GPIO.FALLING, callback=aus, bouncetime=100)
RuntimeError: Conflicting edge detection already enabled for this GPIO channel
Könnt ihr mir Helfen diesen "Schalter" zu programmieren.
Danke schonmal