Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. from gpiozero import Button
  2. import pygame.mixer
  3. from pygame.mixer import Sound
  4. from signal import pause
  5.  
  6. pygame.mixer.init()
  7.  
  8. sound_pins = {
  9. 2: Sound("samples/DrumBuzz.wav"),
  10. 3: Sound("samples/CymbalCrash.wav"),
  11. }
  12.  
  13.  
  14. buttons = [Button(pin) for pin in sound_pins]
  15. for button in buttons:
  16. sound = sound_pins[button.pin.number]
  17. button.when_pressed = sound.play
  18.  
  19. pause()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement