Overview

This project will show you how to turn an Arduino Yun into a soundboard that can be controlled from a webpage over WiFi. Prank your friends or coworkers by hiding the device nearby to remotely trigger sounds that drive them mad! Or keep the device on your desk ready to play just the right laugh track like you're living in an 80's sitcom!

Hardware

You will need the following hardware for this project:
  • Arduino Yun
  • MicroSD card with at least about 20 megabytes of space available.
  • USB audio adapter or USB speakers.
    • If using USB speakers, make sure both the audio and power are transferred over USB. Some USB speakers only send power over USB and audio over a 3.5mm jack--these won't work with the Yun! I had good results with this small laptop soundbar in my project.
Before you get started you will want to have your Yun connected to your wireless network, and be familiar with connecting to the Yun over SSH. Check out the following links for more information on these topics:

Installation

Audio Setup

Make sure the MicroSD card is inserted into the Yun and it is powered on. Connect to the Yun with SSH and execute the following commands to install the audio drivers and software:

opkg update
opkg install kmod-usb-audio
opkg install madplay
opkg install alsa-utils

Once the commands above are executed, connect the USB audio adapter or speakers to the Yun.

Flask Setup

Execute the following commands to prepare python to install the Flask web application framework:

opkg install distribute
opkg install python-openssl
easy_install pip

Next execute the following command to create a directory on the SD card for storing python packages:

mkdir /mnt/sda1/python-packages

This folder will be used to install Flask and other python dependencies. By storing these dependencies on the SD card, there's less concern about using up the very limited storage space on the Yun (only 16 megabytes for the entire Linux installation!).

Execute the following command to install Flask:

pip install --target /mnt/sda1/python-packages flask

Finally update the system profile to set the PYTHONPATH environment variable to point at the python packages folder by executing:

echo "export PYTHONPATH=/mnt/sda1/python-packages" >> /etc/profile

Disconnect from the Yun's SSH session and reconnect again so the PYTHONPATH variable is set.

Software Install

Once the audio and Flask setup steps are complete, you can install the software for this project. While connected to the Yun over SSH, execute the following commands to download the software and unzip it on the SD card:

opkg install unzip
cd /mnt/sda1
wget --no-check-certificate \
https://github.com/tdicola/YunSoundboard/archive/master.zip
unzip master.zip

The folder YunSoundboard-master should be created with the contents of the zip file that was downloaded.

To start the Flask application, execute the following commands:

cd /mnt/sda1/YunSoundboard-master
python Soundboard.py

After a few moments the Flask application should load, and you should see the following text:
* Running on http://0.0.0.0:5000/
* Restarting with reloader


If you see an error, make sure you've carefully followed all the above setup steps and try again.

Once the application is running, open a web browser from a computer or device on your network and access the URL http://arduino.local:5000/.

Note: If you've changed the name of your Yun, change 'arduino.local' in the URL to the name of your Yun with the .local extension. Also if you're using a device that doesn't support mDNS names in URLs (like Windows or Android), instead access
http://ip_address_of_yun:5000/ where ip_address_of_yun is the IP address of the Yun. For example http://192.168.1.110:5000/ would be the URL if your Yun has an IP address of 192.168.1.110.

Press buttons on the web page to make the Arduino play sounds! You can press the STOP button to stop any sound that is playing.

Add Sounds

To add your own sounds to the soundboard you can copy MP3 files into the YunSoundboard-master/sounds folder. On Mac or Linux, use the scp tool to copy a file from your computer to the Yun by executing in a terminal:

cd /path/to/folder/with/MP3s
scp file.mp3 [email protected]:/mnt/sda1/YunSoundboard-master/sounds/

If necessary, change arduino.local to the name or IP address of your Yun.

On Windows you'll need to install the pscp utility. The syntax should be the same as the Mac/Linux command above, except with the 'pscp' command instead of scp. See these instructions for using pscp if you need more help.

Once the sounds are copied over, reload the web page and you should see them added to the list of sounds automatically.

Here are some sources of free sound effect MP3s:
Remember, you can only use MP3 files with the software.

Future Work

This project is a great example of using the Arduino Yun's Linux processor to host a web application and play sounds. After following the steps in this guide you can even create your own Flask web applications that are hosted directly on the Yun.

Some interesting ways you might extend this project include:
  • Run the software on a Raspberry Pi or Beaglebone Black instead of the Arduino Yun. The software should work without changes as long as Flask and madplay are installed.
  • Copy your music collection to the device to make a WiFi controlled boombox. Consider extending the application to shuffle and randomly play the music files.
  • Hook up a PIR motion sensor to the Yun and have the web page tell you if someone is near the device and ready to be pranked!
What can you think of to extend this project?
This guide was first published on May 01, 2014. It was last updated on May 01, 2014.