Creating a child-friendly audio player with the Raspberry Pi

Generating QR codes

You can generate the QR codes for the albums by invoking the program Qrencode from the command line. You should create a small text file qr.txt that contains two entries, artist: and album:, for each QR code. The software outputs the QR code as a PNG file with:

$ qrencode -s 10 -o qr.png < qr.txt

The -s 10 option makes sure the output uses 10 pixels for each data point. This makes the picture somewhat larger and also makes it easier for the webcam to recognize the pattern.

You can build small cards from the album cover and the QR code (Figure  2). You will find a template for this in the form of a LibreOffice file together with other listings in the QRMusic GitHub repository  [11].

Figure 2: The cards with the QR code also contain a picture of the album cover.

Interaction

Many configuration files and scripts interact in this project. Figure  3 provides an overview of the individual components. First, you configure the infrared receiver in /etc/lirc/Logi.conf, then you activate irexec in /etc/lirc/hardware.conf, which in turn processes the button presses of the remote control by means of /etc/lirc/lircrc.

Figure 3: The structure turns out to be relatively complex, but the player is easy to use.

The events produced by the remote control call the script /home/pi/remote.sh, which in turn uses zbarcam to input the QR codes and then passes the input data to the /home/pi/rbar.sh script. The script evaluates the data from the QR code and controls the XMMS2 client accordingly.

To create QR codes, you pass the text files to the QRencode program then print the QR code picture files that have been created, together with the album covers, onto small cards. Alternatively, you can use the gLabels software to produce a series of cards  [12].

Figure  4 shows the finished construction in the children's room. The camera has a bracket made out of Lego blocks because the children found it difficult to hold the cards still long enough to be read accurately. The Rasp Pi and cables were bolted to the underside of the table, so that the only visible components consist of the webcam, the infrared receiver, and the speaker.

Figure 4: A Lego bracket ensures that scanning the QR codes works without problem.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content