mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
17 lines
346 B
Python
17 lines
346 B
Python
from gpiozero import Button
|
|
import pygame.mixer
|
|
from pygame.mixer import Sound
|
|
from signal import pause
|
|
|
|
pygame.mixer.init()
|
|
|
|
button_sounds = {
|
|
Button(2): Sound("samples/drum_tom_mid_hard.wav"),
|
|
Button(3): Sound("samples/drum_cymbal_open.wav"),
|
|
}
|
|
|
|
for button, sound in button_sounds.items():
|
|
button.when_pressed = sound.play
|
|
|
|
pause()
|