Download PDF - Adafruit Learning System

WiFi Yun Soundboard
Created by Tony DiCola
Last updated on 2014-05-01 03:45:23 PM EDT
Guide Contents
Guide Contents
2
Overview
3
Hardware
3
Installation
4
Audio Setup
4
Flask Setup
4
Software Install
4
Add Sounds
5
Future Work
7
© Adafruit Industries
https://learn.adafruit.com/wifi-yun-soundboard
Page 2 of 7
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 (http://adafru.it/1498)
MicroSD card (http://adafru.it/102) with at least about 20 megabytes of space
available.
USB audio adapter (http://adafru.it/1475) or USB speakers.
If using USB speakers, make sure bo th the audio and po wer 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 (http://adafru.it/dni) 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:
Guide to the Arduino Yun (http://adafru.it/d1Z)
SSH communication with the Arduino Yun (http://adafru.it/dh6)
© Adafruit Industries
https://learn.adafruit.com/wifi-yun-soundboard
Page 3 of 7
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 (http://adafru.it/cFR)
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
© Adafruit Industries
https://learn.adafruit.com/wifi-yun-soundboard
Page 4 of 7
Software Install
Once the audio and Flask setup steps are complete, you can install the software for this
project (http://adafru.it/dnj). 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 (http://adafru.it/dnk)
unzip master.zip
The folder YunSo undbo ard-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/ (http://adafru.it/dh8)
* 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/ (http://adafru.it/dh9).
No te: 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/ (http://adafru.it/dnl) where ip_address_o f_yun is the IP
address of the Yun. For example http://192.168.1.110:5000/ (http://adafru.it/dnm) 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
YunSo undbo ard-master/so unds 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
© Adafruit Industries
https://learn.adafruit.com/wifi-yun-soundboard
Page 5 of 7
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 (http://adafru.it/aWh). 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 (http://adafru.it/dnn) 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:
Soundbible.com (http://adafru.it/aU0)
Soundjay.com (http://adafru.it/dno)
freeSFX (http://adafru.it/dnp)
Remember, you can only use MP3 files with the software.
© Adafruit Industries
https://learn.adafruit.com/wifi-yun-soundboard
Page 6 of 7
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 (http://adafru.it/dnq) 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 (http://adafru.it/cFR)and
madplay (http://adafru.it/dnr) 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 (http://adafru.it/189) 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?
© Adafruit Industries
Last Updated: 2014-05-01 03:45:23 PM EDT
Page 7 of 7