Introduction: Raspberry Pi MP3 Player

About: I loves making arduino stuff and also coding. Its fun and also makes me feel like goin to future :D

Raspberry Pi actually isn't good for making MP3 Player. But this objective of this project is to know how to use GPIO Pins.

A general-purpose input/output is an uncommitted digital signal pin on an integrated circuit or electronic circuit board whose behavior—including whether it acts as input or output—is controllable by the user at run time. GPIOs have no predefined purpose and are unused by default.
- Wikipedia guy

Target : Using GPIO and Making your Pi headless

Target Audience : Medium - Knows how to solder, understand how Pi works, able to boot an operating system and knows about wiring.


Here's what we need :

  1. Raspberry Pi
  2. Buttons x3
  3. Pendrive
  4. Our cardboard friend :)
  5. Breadboard
  6. Wires

Additional components for Raspberry Pi Zero

  1. HDMI(With sound for RPI Zero)
  2. USB Hub

Step 1: Flash SD Card

Download Etcher, and the Raspbian Image. And then install Etcher. If you are done, open it and open the Raspbian Image via Etcher. Insert your SD Card and choose it in Etcher. Click Flash. After done flashing, Insert it in your Raspberry Pi. You might wondering, actually why need to flash?

The reason :

Our Pi is empty. Its like a human body without organ to operate. If you insert Organ(Flashed Memory card), the body(Pi) can operate.

Step 2: Plug Everything

Plug everything. Which is the Hdmi(With Sound for Pi Zero), Power source, Keyboard and Mouse.

Note for Pi Zero User :

Yes, I understand. I am also poor. Thats why I only buy Pi Zero. Just buy a USB Hub and plug it through the OTG.

When the Pi booted up, finish the configuration.

Step 3: Insert Song and Wrapper to Your Pi

Insert all songs(Mp3) to your Pendrive first. And then download this Wrapper and insert to your pendrive.

"What is this? A virus?"

This is called wrapper. You can use GPIO to control OMXPlayer by using this wrapper.

Also, credit to Jehutting for making this script! :D

Once you're done, plug the pendrive to the Pi. And move the song to /home/pi/Music/

Move the wrapper to the /home/pi/Desktop

Now we just insert a song and its operator. Now lets make them automaticaly open when we boot the Pi.

Step 4: Make the Pi Play the Song on Startup

In order to do this, you need to adjust a file to runs the player.

Open Terminal


sudo nano /etc/profile

Explanation : Sudo is to grant access at your command. And Nano is like a text editor. The /etc/profile is what we want to edit. Its like opening a .txt file instead you use command.

And then, Scroll to the bottom. And add this line :

sudo python /home/pi/Desktop/ /home/pi/Music

"What is this code?" You may ask, This code is to open the wrapper and play a song at where we saved them, "/home/pi/Music"

Now, press "Ctrl + x" and then press Y, and Enter.

Now lets see if it plays the song on reboot. Type :

Sudo reboot

If it works, then we can continue to the magic!

Step 5: Do Magic Using Gpio Pins

Now its time for you to start using GPIO Pins! They kinda seem like Arduino but its different.

Now, I am going to show the trick. Connect the pin(Based on the reference), GPIO24 to 3v3 and see the magic.

"Wow! The song changed! Its magic, mom get the camera!"

Of course everyone likes playing with GPIO Pins :)

But this is just the start, in a normal MP3 Player, we have 3 buttons. Next, Play/Pause and Previous.

Lets use this Magic and make the buttons!

Step 6: Adding Buttons

Yes! We are getting hyped! Use a breadboard and connect them based on the diagram I made.

Note that the Pi Zero has the same pin position so don't worry about it.

After done, Try booting up the Pi and click the buttons. We now have 3 buttons. Previous, Pause/Play and Next.

Well, Lets turn it into Cute Cardboard MP3 Player!

Step 7: Solder the Buttons

We need to solder them so they get smaller and fits with the box. If you aren't familiar with breadboard, its like combining the wires but by placing them on the "bread"board. We need a smaller one.

Based on the breadboard prototype we made, try to check "How it works?"

How can they connected even if you didn't connect the wire? Try checking every single side, looking how it works. If you figured it out, you can start soldering!

Step 8: Insert Them Into a Box

Cut the cardboard that fits with your pi and other accessories. And Insert them. For the Button, we need to cut the cardboard like at the picture shown above same as making a space for the usb cable and Earphone jack port so they can get out.

And here we go!

We just made a cool MP3 Player

Hope you enjoy :)

Step 9: Finished!

You just made MP3 Player! And we also learnt about GPIO pins.

I hope you enjoys!

Cardboard Speed Challenge

Participated in the
Cardboard Speed Challenge