Hello, my next project is, as I use to do, a not very useful project :
This a jukebox based on a Raspberry 3 B+
I know , something like this can be easily done with a smartphone and a Bluetooth speaker.
But for my project, I had two hard prerequisites:
I wanted to make something "vintage".
And overall, given the fact that my lady is definitively hopeless for computer or bluetooth or anything else from 21th century,(and even 20th), I had to do something very simple to use.........
So,the specifications were as follow:
One single push button to start the machine
A touch screen (very simple) to manage the music.
A single touch on the screen to stop the machine.
And to have a good sound .........
For this I used:
1 Raspberry 3 B+
1 old home cinema that was useless due to DVD reader OOS (an old Samsung 2.1 with a woofer and 2 speakers that I modified to fit to the box)
1 HIFIBERRY DIGI+ board (with optical output for the power Amp)
1 capacitive touch screen 7" (mine is Makeasy for raspberry with HDMI input and powered via USB but any HDMI touch screen should be OK)
1 power suplly 5V 5A
1 relay shield
1 Arduino nano to manage the power ON/OFF process
1 IR led to drive the home cinema (led driven by a 2N2222 NPN transistor)
1 IR receiver (for the IR codes learning part of the project, I get mine from an old Multimedia hard disk with remote command)
1 switch for maintenance mode
1 switch for working on the arduino (during the upload the arduino is reseted)
some JST and Dupont connectors
And for the box
Wood and plywood (but I will not describe deeply the making of the box). just to say that, regarding the boomer inside the box, 10 mm plywood and 18 mm wood are mandatory if you don't want to see the Jukebox crossing the living room while playing !!!!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Raspberry Part Description:
The Raspi has to manage different things:
1) the commands to the home cinema (via IR remote)
2) the music files
3) the touch screen
4) The heartbeat to the Arduino (wich manage the Wdt (watch dog timer))
I started from a Raspbian strech distribution on a 16 G SD card (As we will only read files from the SD card , the use of a HDD is not necessary). I will not spend time on this part as the web is full of tuto about it..
Let's see the different parts in the next steps....
Step 2: The IR Remote Codes
As I could'nt find the circuit plan of the home cinema, I decided to drive it via remote commands
The first step I had to complete was to learn to Raspi the codes of the Home cinema remote command.
for that I used the very good tuto in Instructables from Austin Stanton IR codes
I had some differences, probably due to new version as the instructables is rather old, the hardware.conf file no longer exists (at least I didn't find it)
It seems also that the transistor used in the tuto is a PNP transistor ,for my part I used a 2N2222 which is NPN but the result is the same.(except the cabling !!!!!!!!)
The pin assignment is given in /boot/config.txt:
#autorisation de lirc le 08/07/2019
The IR LED will be so connected to pin22 of the Raspi.
One important remark : when learning the codes to Raspi it is mandatory to use the keywords listed in the command
Here is the file I built for my jukebox:
pi@raspitone:/etc/lirc $ cat lircd.conf
# Please take the time to finish this file as described in # https://sourceforge.net/p/lirc-remotes/wiki/Check... # and make it available to others by sending it to # #
# This config file was automatically generated
# using lirc-0.9.4c(default) on Thu May 9 17:33:37 2019 # Command line used: -d /dev/lirc0 /root/lircd.conf
# Kernel version (uname -r): 4.14.98-v7+ # # Remote name (as of config file): jukebox
# Brand of remote device, the thing you hold in your hand: # Remote device model nr:
# Remote device info url:
# Does remote device has a bundled capture device e. g., a
# usb dongle? :
# For bundled USB devices: usb vendor id, product id
# and device string (use dmesg or lsusb):
# Type of device controlled
# (TV, VCR, Audio, DVD, Satellite, Cable, HTPC, ...) :
# Device(s) controlled by this remote:
header 4470 4496
one 542 1693
zero 542 581
As you can see, I just need 4 commands to drive the Home Cinema
AUX => to switch to the optical input channel (as the HC always starts on DVD reader)
And Volume +/-
The related commands are executed via the LIRC commands :
for example: "irsend SEND_ONCE jukebox KEY_VOLUMEUP"
Step 3: Main Programm
The main programm is written in Python :
As I am new in Python I guess there is a lot of improvement that can be done , but it runs....
1) manage the graphical screen:
For this , I used APPJAR which is TKINTER but civilized for student (my case) , this means much easier to use , probably with less possibilities, but it was enough for my purpose.
2) play the mp3 files:
I used mplayer for python.
3) generate random numbers for playing in shuffle mode:
As I didn't want to hear the same song every quarter, I built a small programm to check if the number was not present in the x previous numbers list (x depending on the length of the playlist).
The randint function in python is not so "random" as far as I saw.
4) send the "heartbeat" to the Arduino
5) manage files player:
As Mplayer is asynchronous, when the file is started there is no way to know for Python when it's finished (at least I didn't find a simple way)
To resolve that I used the mplayer commands giving the length of the file and the progress in the current file
For both 4 and 5 I used the possibility given by Appjar to generate a periodic task (as appjar is an event programm this is a way to create a periodic event). the function is:
#******************* start taskman **********************
Taskman for "task manager" which is a def in the programm that manage all what is not screen events (end of the played file, populate progress bar, send heart beat to Nano,....)
Once started the screen looks like this:
Here is the programm:(can be opened via Notepad++ or Geany)
Step 4: Raspberry Part :autostart and Adding New Files
If you look at the programm you can see that I use some bash files :
1) Start_jukebox :
In fact the purpose is to power on the Home cinema and to shift to the D.IN input (optical input in my Home cinema)
pi@raspitone:/bin $ cat start_jukebox
irsend SEND_ONCE jukebox KEY_POWER
irsend SEND_ONCE jukebox KEY_AUX
To power Off the Home cinema
pi@raspitone:/bin $ cat stop_jukebox
irsend SEND_ONCE jukebox KEY_POWER
These two bash files are called by Python with the os.system command
To start the Python script I made a small bash :
pi@raspitone:~ $ cat dem_jukebox.bash
For the auto start in GUI mode I just modified the autostart file in /etc/xdg/lxsession/LXDE-pi
pi@raspitone:/etc/xdg/lxsession/LXDE-pi $ cat autostart
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
Adding new mp3 files:
To add new files , I preferred to make a small dedicated Python script :
I will first explain the system files organization :
All the files are in /home/pi
mp3 files are strored in /home/pi/Music directory
Each artist has his own sub directory hosting the related mp3 files
pi@raspitone:~/Music/Mike_oldfield $ ls -l
-rwxr----- 1 pi pi 2254923 juin 30 2017 A_New_Beginning.mp3
-rwxr----- 1 pi pi 2691736 juin 30 2017 Arrival.mp3
-rwxr----- 1 pi pi 8383244 juin 30 2017 Ascension.mp3
-rwxr----- 1 pi pi 5410816 juin 30 2017 Blue_Night.mp3
-rwxr----- 1 pi pi 13125199 juin 30 2017 Castaway_(Instrumental).mp3
-rwxr----- 1 pi pi 12903583 juin 30 2017 Castaway.mp3
-rwxr----- 1 pi pi 2969869 juin 30 2017 Celt.mp3
-rwxr----- 1 pi pi 9047745 juin 30 2017 Chariots_(Instrumental).mp3
-rwxr----- 1 pi pi 9403263 juin 30 2017 Chariots.mp3
In the directory Documents we can find the built list of files to play.
pi@raspitone:~/Documents $ cat list.txt
We also can find the playlists data (but this is built by the Python script)
The small Python script adds the new songs, saved in Music, in the list.txt after having formatted the tittles in UNIX format
Here is the script:(can be opened via Notepad++ or Geany)
Step 5: The Power Management Via Arduino Nano
As I wanted to have something easy to start, I decided to make it done by a small nano:
When pushing the start button the devices are all powered , the nano starts (1 or 2 seconds ) and takes over the power management by triggering a relay which shunts the push button contacts.
Then Nano waits for 35 seconds to receive the heartbeat from Raspberry (means that start process is complete and the jukebox programm runs).
As long as nano receives the heartbeat it keeps the relay on (Watch dog timer)
If no heartbeat anymore (means the jukebox programm is stopped) Nano waits for 20 seconds (to be sure that the raspi is completely stopped) to release the power relay .
The jukebox is then totaly powered Off
I added a switch to activate an input of the nano to indicate maintenance mode (I use the jukebox to manage my other raspi servers via ssh et vnc) . Nano then deactivates the watch dog process
the input for the heartbeat from Raspi needs to be pulled down (but the 3.3V from Raspi is considered as high level by Nano)
It could be done with NE555 but I am lazzy and have always some nano's in my drawer !!!!
Here is the short C programm (can be opened with Notepad++)
Step 6: The Cabling
For the Screen:
A HDMI cable and a USB cable are used on Raspi to power and drive the screen.
For the front panel:
A USB cable is also connected from the Raspi to be able to upload new files or make backups.
A USB cable is connected from the Nano to be able to access the soft (for modifications if necessary)
I plug also a wireless keyboard dongle on the raspberry to be able to make maintenance without using the external USB plug
As Raspberry and Arduino are used , the cabling is rather simple .
All is located on a strip matrix board.
From raspberry 2 GPIO are used:
Pin22 for IR LED
Pin 27 for heartbeat to Arduino
Pin 2 is used as an interrupt pin for the heartbeat from Raspi.
Pins 3 to 5 are used for driving the led's (Start,Wdt,Maintenance).
Pin 6 is for the maintenance switch.
Pin 7 is output to relay shield .
Here is the fritzing file:
Step 7: The Box
I will not describe a lot what I did as it depends on the power amp and on the speakers used .
As information the home cinema is located in the bottom of the box.
Just over the speakers:
2 medium speakers, that I modified to insert them in the box.
On the top :
The front pannel with the screen, the LED's, the switches and the USB plugs.
For the speakers, the side pannels the top and the bottom I used 18 mm wood plank.
The front side is 10 mm plywood with 40 mm screws.
To facilitate the cabling and the maintenance (if needed!!!) I put the circuitry on a drawer behind the front pannel
To avoid overheating a big hole is done on the bottom of the rear pannel and I put a 5V fan (8 cm ) on the rear pannel just beside the circuitry.
The picture above is just to give an idea.
So, that's it !!!!!!!!!
Thank you for reading me
And see you next time for new adventures