1

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 :)

  • 1
    Its also possible that there could be a fault in your circuit, so I suggest posting some pictures of that. You've posted rather a lot of code here, I suggest going through each section of it until you are certain you have found the bit that is giving an odd result. As it stands you question is quite unanswerable given the huge amount of code and somewhat lack of context. – Darth Vader Apr 29 '17 at 14:32
  • 1
    Thanks for the feedback, Ill edit the post to try to add some more context – Barnaby Hewitt Apr 29 '17 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.