I'm trying to get an audio playback system on a Raspberry Pi to play back a selected sample in Python when the GPIO detects an input from an Arduino, (stepped down to 3.3V).
Here a simplified section of code that I think I may have formatted wrong, attempting to call back 'KickPressed'
` GPIO.setup(12, GPIO.IN) #Set GPIO inputs GPIO.add_event_detect(12, GPIO.RISING) #Detect rising peaks of GPIO from Tkinter import * TKINTER SETUP ECT... def KickPressed(): #Play kick when button/GPIO is pressed play_music(kicksample, volume) time.sleep(0.001) Kbutton = Button(root, text = 'Kick', command = KickPressed) #Button For Kick kicksample = '' while True: if GPIO.event_detected(12): KickPressed() elif GPIO.event_detected(16): SnarePressed() root.mainloop()
I have a feeling the issue may be within the IF statement, but I'm not totally sure - I'm very new to Python and coding in general.
Hope someone is able to help :)