Description
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.
Video
no action, but informative
Part List
- 1 Raspberry Pi
- 1 USB Soundcard
- 1 USB Flash Drive
- 1 Micro Sd Card
- 1 Power Supply
- 1 Enclosure
Software
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:
[Unit]
Description=PlayMP3
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/python /home/play.py
[Install]
WantedBy=multi-user.target
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:
/dev/sda1 /mnt/usb
Ready to use
Shorting the GPIO 17 with the ground, makes the thing do what the thing should do.