pushbutton music player using raspberry pi by: paul baek
DESCRIPTION
Pushbutton Music Player Using Raspberry Pi By: Paul Baek. Materials. Breadboard 7 push buttons 7 10k ohm resistors - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/1.jpg)
Pushbutton Music Player Using Raspberry PiBy: Paul Baek
![Page 2: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/2.jpg)
MaterialsBreadboard7 push buttons7 10k ohm resistorsRaspberry Pi Budget pack from Adafruit.com
Budget pack includes the following:GPIO Kit, Wires, 4 GB SD card, Raspberry Pi enclosure, Raspberry Pi power supply, small breadboard.
Raspberry Pi
![Page 3: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/3.jpg)
Raspberry Pi
![Page 4: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/4.jpg)
What is it?The Raspberry Pi is a Linux based computer
that is about the size of a credit card. It can be used for computing, however, it is best used for personal projects and/or used as an embedded device.
The ability to connect to and program it’s GPIO pins allow the user to connect sensors, buttons, switches, etc. to the Raspberry Pi.
![Page 5: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/5.jpg)
Objectives
To make something practical that I can also use at home.
I wanted to create a music player that doesn’t run on my PC so I can reduce processing power used.
Make it controllable with push buttons.
![Page 6: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/6.jpg)
Wiring the Breadboard
![Page 7: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/7.jpg)
Button Schematic
![Page 8: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/8.jpg)
Wiring / Button Layout
![Page 9: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/9.jpg)
Python CodeKey points
![Page 10: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/10.jpg)
Key Press FunctionMPG321 uses the Control+C key press to
skip forward to the next song. To bind this to a push button, I had to create a special function and variable.
![Page 11: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/11.jpg)
Contol C functionControl_c_sequence = ‘ ‘ ‘keydown Control_L
key ckeyup Control_L‘ ‘ ‘
Def keypress(sequence):p=Popen([‘xte’], stdin=PIPE)p.communicate(input=sequence)return 0;
![Page 12: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/12.jpg)
Signal interruptAn issue I came across when using the
control c input was that it’s the program shutdown button for python. I had to find a way to block the shutdown signal, so I created a function to do just that.
![Page 13: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/13.jpg)
SIGINT functionDef sigint_handler(signum, frame):
passThe following line of code had to be inserted
after the keypress sequence:signal.signal(signal.SIGINT, sigint_handler)
![Page 14: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/14.jpg)
Reading the GPIO input
![Page 15: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/15.jpg)
Put it all together and you get….
![Page 16: Pushbutton Music Player Using Raspberry Pi By: Paul Baek](https://reader030.vdocuments.net/reader030/viewer/2022032606/56812d15550346895d91fc98/html5/thumbnails/16.jpg)
Music Player Demo