Update music box recipe

This commit is contained in:
Ben Nuttall
2017-01-08 11:36:43 +00:00
committed by GitHub
parent 06e534b537
commit c586fe07f5

View File

@@ -5,14 +5,12 @@ from signal import pause
pygame.mixer.init()
sound_pins = {
2: Sound("samples/drum_tom_mid_hard.wav"),
3: Sound("samples/drum_cymbal_open.wav"),
button_sounds = {
Button(2): Sound("samples/drum_tom_mid_hard.wav"),
Button(3): Sound("samples/drum_cymbal_open.wav"),
}
buttons = [Button(pin) for pin in sound_pins]
for button in buttons:
sound = sound_pins[button.pin.number]
for button, sound in button_sounds.items():
button.when_pressed = sound.play
pause()