mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Update music box recipe
This commit is contained in:
@@ -5,14 +5,12 @@ from signal import pause
|
|||||||
|
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
|
|
||||||
sound_pins = {
|
button_sounds = {
|
||||||
2: Sound("samples/drum_tom_mid_hard.wav"),
|
Button(2): Sound("samples/drum_tom_mid_hard.wav"),
|
||||||
3: Sound("samples/drum_cymbal_open.wav"),
|
Button(3): Sound("samples/drum_cymbal_open.wav"),
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons = [Button(pin) for pin in sound_pins]
|
for button, sound in button_sounds.items():
|
||||||
for button in buttons:
|
|
||||||
sound = sound_pins[button.pin.number]
|
|
||||||
button.when_pressed = sound.play
|
button.when_pressed = sound.play
|
||||||
|
|
||||||
pause()
|
pause()
|
||||||
|
|||||||
Reference in New Issue
Block a user