Guten Morgen,

Ich habe ein problem mit meinem skript. Ich möchte gerne, dass wenn man einen kliptaster betätigt dieser in einem array gespeichert wird. Leider wird die Zahl des Tasters doppelt im array angezeigt. Er ruft bei mir die function zweimal auf.

import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
import time
import sys, traceback
 
#https://raspberrypihq.com/use-a-push-button-with-raspberry-pi-gpio/
 
tastenSeq=[]
 
 
def button_callback(channel):
       print("Taster 2: AN")
       GPIO.output(12,True)
       tastenSeq.append(2)
       time.sleep(1.0)
       GPIO.output(12,False)
       print("Taster 2: AUS")
 
 
def button_callback2(channel2):
       print("Taster 5: AN")
       GPIO.output(32,True)
       tastenSeq.append(5)
       time.sleep(1.0)
       GPIO.output(32,False)
       print("Taster 5: AUS")
       print tastenSeq
 
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(32,GPIO.OUT)
 
GPIO.setwarnings(False) # Ignore warning for now
#GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
 
GPIO.setup(31, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin and set initial value to be pulled low (off)
GPIO.add_event_detect(31,GPIO.RISING,button_callback) # Setup event on pin 10 rising edge
 
 
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input p$
GPIO.add_event_detect(15,GPIO.RISING,callback=button_callback2) # Setup event on p$
 
message = input("Press enter to quit\n\n") # Run until someone presses enter
GPIO.cleanup() # Clean up