Introduction: Fart Machine (using Linkit One)

Yes, you read the title correctly. This is an automatic fart noise generator. It is a linkit one with one of two motion detectors hooked up to it. When someone or something moves nearby it plays a fart noise.

This of course could be any noise and the code here could be used to trigger any number of things (spooky sounds at halloween, a doorbell chime for your office, home security, etc.). However, the fact is, farts are funny, universally funny. Just ask my 6 year old.

Thank you to Mediatek for seeding the community with these boards. They are pretty nifty.

Step 1: Materials

-A linkit one ( ) - this project is great example of where this board shines. It has audio playback and file storage capabilities built right in. A regular arduino or arduino clone would require an SD card capability (for storage) and an audio playback board. This would easily cost more and because of the lack of a unified board open up more error possibilities.

-A speaker of some type - I used an old crummy speaker I had in the garage.

-The battery that comes with the linkit one board

-A fart mp3 file (more on that later) -A Grove PIR Motion Sensor ( OR a Grove IR distance interruptor (

-A micro usb cable for putting a sketch on the board and loading audio files into it’s storage

Step 2: Setup

Follow what is here:

This guide is pretty comprehensive. You don’t have to have the GPS and networking components working, but if you can upload code and blink and LED then you are good to go.

Step 3: Get a Fart Mp3 on Your Linkit One

If you go to you will find there are any number of free sample noises for you to use in projects (please check the licensing with whatever you chose).

Make sure what you are getting is an mp3. While some of the documentation seemed to indicate that wav files are supported, I had my best luck with mp3’s.

Switch your linkit one into mass storage mode (select ms on the small slider and usb on the larger one). Then plug in the linkit one into your computer using the usb cable. It should appear as a mass storage device. Drop in the mp3 you chose and give it a simple name (in my code I used “19.mp3”).

Step 4: Hook Everything Together

Plug the battery into your linkit one.
Wire up the sensor as shown in the pictures. I don’t have a Grove backpack shield for my linkit one and so I use jumper wires stuck in the molex connector. Red (power) goes to 5v, Black to Ground, and the D1 to the D2 (digital 2) pin on your linkit one. There is also a pin on the sensor labeled “NC.” This stands for “no connect” and you don’t have to do anything with it.

Both of the sensors hook up the same way, but work differently. The real reason I mention two sensors is because my PIR motion sensor is broken and the IR sensor is a good stand in (with the limitation of working only at close distances and the need to switch pin logic (more on that later)).

Also note the IR sensor needs adjusting the first time you use it. Check this page for the how to:

Step 5: Flash the Code

-Use the stuff you learned in that setup tutorial to guide you here.

Step 6: Start Things Up and Get to Farting

I have issues with starting my linkit one consistently with battery power. Usually I’d say just go with usb power, but if you are realistically going to deploy this device as a prank then you will want to use the battery.

Here are my steps for starting with the battery:

  • Set the switches to USB and UART
  • Plug in the battery Switch from UART to MS
  • Switch to BATT
  • Switch to UART

Step 7: Code Walkthrough

The code here is kept extremely simple. You can easily make it more complicated by adding multiple farts, timing them out, rotating them at random, etc.

The code presented here is based largely on these two examples:


/* Automatic farts
* sound generator that plays random fart noises when motion is detected * For use with the Mediatek Linkit One and a Grove PIR motion sensor * You will also need something like a speaker to play the far noise on */

#include <LAudio.h>

#define MOTION_SENSOR 2 //Use pin 2 to receive the signal from the module

void setup() { LAudio.begin(); Serial.begin(115200); LAudio.setVolume(6); pinMode(MOTION_SENSOR, INPUT); LAudio.playFile(storageFlash,(char*)"19.mp3"); }

void loop() { if(isPeopleDetected()){//if it detects the moving people? Serial.println("person detected!"); LAudio.playFile(storageFlash,(char*)"19.mp3"); delay(2000); } }

boolean isPeopleDetected() { int sensorValue = digitalRead(MOTION_SENSOR); if(sensorValue == LOW)//if the sensor value is HIGH? { return true;//yes,return true } else { return false;//no,return false }

In the setup function the audio code is initiated, a volume of “6” is selected (6 is the highest), the pinMode for the motion sensor is set as input (which means whatever is plugged into that pin will set it to high or low). Then it plays the mp3 file.
In the loop section the “isPeopleDetected” function is called to see if motion has been detected and if it has the file is played.

isPeopleDetected has its logic set so a “LOW” pin reading means that there is motion. The works for the IR Distance Interrupt sensor but not for the PIR motion detector sensor. For that you have to change the LOW to a HIGH.

Step 8:


DIY+Hacks+and+How+Tos made it!(author)2015-11-22

Great application for a Linkit one.

About This Instructable




More by JustinN1:Fart Machine (using Linkit one)Super simple dashboarding directly on the linkit oneLinkit One Serving JSONP sensor data (battery example)
Add instructable to: