It’s just a small project. A friend of mine asked me, for an mp3 player, which each time you close a contact, plays randomly a song.
The raspberry pi was predestinated for this. The sound output of the Pi is not optimal, so I used a 7$ USB Soundcard.
no action, but informative
- 1 Raspberry Pi
- 1 USB Soundcard
- 1 USB Flash Drive
- 1 Micro Sd Card
- 1 Power Supply
- 1 Enclosure
The pi is running on Arch Linux (booting up in under 25sec). You also need python 3.5, the RPI.GPIO package and mpg123
In the home directory you need this 3 files. You can find them here GitHub
- play.py (main program)
- mp3.sh (play the mp3)
- system.mp3 (sound file)
create a folder “mp3” on the flash drive and copy all the needed mp3’s in it
Start on boot
Create a file under /usr/lib/systemd/system and name it “playmp3.service”
Copy this inside the file you just created:
To run the system on boot, do the following:
systemctl enable playmp3.service
Now create this directory mkdir /mnt/usb
open the file /etc/fstab and add the following line:
Ready to use
Shorting the GPIO 17 with the ground, makes the thing do what the thing should do.