# WiFi Yun Soundboard

## Overview

https://www.youtube.com/watch?v=2QYVcFGic9E&amp;feature=youtu.be

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](https://www.adafruit.com/products/1498)
- [MicroSD card](https://www.adafruit.com/products/102) with at least about 20 megabytes of space available.
- [USB audio adapter](https://www.adafruit.com/products/1475) 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](http://www.radioshack.com/product/index.jsp?productId=18920016) 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://arduino.cc/en/Guide/ArduinoYun)
- [SSH communication with the Arduino Yun](http://arduino.cc/en/Tutorial/LinuxCLI)

# WiFi Yun Soundboard

## 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://flask.pocoo.org/) 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](https://github.com/tdicola/YunSoundboard). 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](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/](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/](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/](http://ip_address_of_yun:5000/ "Link: 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/](http://192.168.1.110:5000/ "Link: 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 root@arduino.local:/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://www.chiark.greenend.org.uk/~sgtatham/putty/download.html "Link: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html"). 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://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html) 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://soundbible.com/)
- [Soundjay.com](http://www.soundjay.com/)
- [freeSFX](http://www.freesfx.co.uk/)

Remember, you can only use MP3 files with the software.  
# WiFi Yun Soundboard

## 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://flask.pocoo.org/docs/quickstart/) 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://flask.pocoo.org/)and [madplay](http://www.underbit.com/products/mad/) 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](https://www.adafruit.com/products/189 "Link: https://www.adafruit.com/products/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?  

## Featured Products

### Arduino YUN (YÚN)

[Arduino YUN (YÚN)](https://www.adafruit.com/product/1498)
 **Arduino Yún 云**  
  
Arduino Yún is the first member of a new groundbreaking line of wifi products combining the power Linux with ease of use of Arduino.  
Yún means “cloud” in Chinese language as the purpose of this board is to make it simple to...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1498)
[Related Guides to the Product](https://learn.adafruit.com/products/1498/guides)
### USB Audio Adapter - Works with Raspberry Pi

[USB Audio Adapter - Works with Raspberry Pi](https://www.adafruit.com/product/1475)
The Raspberry Pi has an on-board audio jack, which is super handy for all kinds of sound effects and speech, just plug and go! However, for when you want better audio for music playback, a USB audio card can greatly improve the sound quality and volume. That's because the on-board audio is...

In Stock
[Buy Now](https://www.adafruit.com/product/1475)
[Related Guides to the Product](https://learn.adafruit.com/products/1475/guides)
### Raspberry Pi Model B 512MB RAM

[Raspberry Pi Model B 512MB RAM](https://www.adafruit.com/product/998)
Adafruit ships the **Raspberry Pi Model B 512MB RAM** as of 10/18/2012.  
  
The Raspberry Pi® is a single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of stimulating the teaching of basic computer science in schools. The Raspberry...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/998)
[Related Guides to the Product](https://learn.adafruit.com/products/998/guides)
### BeagleBone Black - Rev B

[BeagleBone Black - Rev B](https://www.adafruit.com/product/1278)
**[Adafruit is no longer shipping the BeagleBone Black Rev B, it has been replaced with the Rev C as of 5/12/14](https://www.adafruit.com/products/1876) - the Rev C now has 4G flash and also comes with Debian, it also costs slightly more. There are no exchanges or...**

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1278)
[Related Guides to the Product](https://learn.adafruit.com/products/1278/guides)
### SD/MicroSD Memory Card (8 GB SDHC)

[SD/MicroSD Memory Card (8 GB SDHC)](https://www.adafruit.com/product/1294)
Add mega-storage in a jiffy using this 8 GB class 4 micro-SD card. It comes with a SD adapter so you can use it with any of our shields or adapters. Preformatted to FAT so it works out of the box with our projects. Tested and works great with our <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1294)
[Related Guides to the Product](https://learn.adafruit.com/products/1294/guides)

## Related Guides

- [Dimmable Li-Ion Halogen Bike Light](https://learn.adafruit.com/dimmable-li-ion-halogen-bike-light.md)
- [LEGO Set Lighting](https://learn.adafruit.com/lego-set-lighting.md)
- [Apple Newton - A Personal Digital Assistant from 25 years ago](https://learn.adafruit.com/apple-newton-personal-digital-assistant.md)
- [Onion Pi](https://learn.adafruit.com/onion-pi.md)
- [Rotary Phone Dial Keypad](https://learn.adafruit.com/rotary-phone-dial-keypad.md)
- [Modifying Servos for Continuous Rotation](https://learn.adafruit.com/modifying-servos-for-continuous-rotation.md)
- [Crayola Scented Candle](https://learn.adafruit.com/crayola-scented-candle.md)
- [How to Set Up 2-Factor Authentication on Adafruit](https://learn.adafruit.com/how-to-set-up-2-factor-authentication-on-adafruit.md)
- [Protect Your Online Accounts with Strong Passwords & Password Managers](https://learn.adafruit.com/protect-your-social-media-online-accounts-with-a-strong-password-manager.md)
- [Colorful Creations with the New JLCPCB PCB Service](https://learn.adafruit.com/colorful-creations-with-the-new-jlcpcb-pcb-service.md)
- [Hacking Yoto Music Players](https://learn.adafruit.com/hacking-the-yoto-music-players.md)
- [CircuitPython on the Xteink X4 eReader](https://learn.adafruit.com/circuitpython-on-the-xteink-x4-ereader.md)
- [Commodore 64 - The Most Popular Retro Computer of All Time](https://learn.adafruit.com/commodore-64-retro-guide.md)
- [Hacking the Kinect](https://learn.adafruit.com/hacking-the-kinect.md)
- [Jack-o'-LED·trix](https://learn.adafruit.com/jack-o-led-trix.md)
