Let’s have a little fun. Let’s turn a raspberry pi into an Internet controlled whoopee cushion.
So, the idea is pretty simple. We run a server program on the raspberry pi. This program will respond to commands that we send it. In this case, we only need one command: fart. Then we hide the raspberry pi next to a family member, friend, coworker, etc. and tell the raspberry pi to fart. Hilarious every time.
Steps
1) Download the attached code. There should be two files FartMachineServer.cpp and FartMachineClient.cpp.
wget http://www.element14.com/community/servlet/JiveServlet/download/38-119332/FartMachine.zip
unzip FartMachine.zip
2) The above code uses the Boost C++ libraries. So, download and install them:
sudo apt-get install libboost-all-dev
3) Download your favorite fart sound. The one that I used (fart-01.wav) can be found here:
wget http://www.soundjay.com/human/fart-01.wav
4) Compile the server:
g++ -lboost_system -lboost_thread FartMachineServer.cpp -o FartMachineServer.exe
5) Compile the client. This should be done on the machine that you want to issue the fart command. (Remember to install boost on this machine, if it is not already installed):
g++ -lboost_system FartMachineClient.cpp -o FartMachineClient.exe
6) Get the IP address (inet addr) of the raspberry pi:
ifconfig
The IP address will typically be something like 192.168.XXX.XXX. (Mine is 192.168.1.100) This IP address will work if you are on the same local network. If you are outside of the local network, you will need to set up port forwarding.
7) Pick your favorite port (mine is 1554) and start the server on the raspberry pi:
./FartMachineServer.exe 1554
8) Run the client code, passing it in the IP address from step 6) and the port number from step 7):
./FartMachineClient.exe 192.168.1.100 1554
9) Listen to beautiful flatulence and laugh.
Troubleshooting
1) The code is expecting the name of the audio file to be fart-01.wav and reside in the same directory as FartMachineServer.exe. If this is not the case, they you will have to change the source code to point it to the correct location and recompile (step 4).
2) Verify that the sound works on your raspberry pi. The following article gives a very detailed explanation of how to do that:
http://www.raspberrypi-spy.co.uk/2013/06/raspberry-pi-command-line-audio/
More Information
The code is based on the Boost blocking TCP example, which can be found here:
http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/examples/cpp03_examples.html








