I am making a drum kit and I want to sense multiple inputs simultaneously. (Like a real Drum Kit!)
I have different channels set up in Pygame for each input and so there isn't any flaw with that. I want to find a way to sense multiple inputs at the same time.
Here is a snippet of the code----
Code: Select all
try:
while True:
while True:
if GPIO.input(29) ==1:
channel1.play(pygame.mixer.Sound(Drum1))
time.sleep(0.02)
break
if GPIO.input(31) ==1:
channel2.play(pygame.mixer.Sound(Drum2))
time.sleep(0.02)
break
#There are six more of these exact codes, just the GPIO number, the channel number, and the "Drum" number is changed.
But don't worry, it works fine...)
I have defined things like GPIO, channel1, Drum1 earlier, so don't worry about that.
This is the exact code I use, and it works fine. Please note that the time.sleep command is to avoid multple sounds from the same input.
Please help!!!
Thank you!