Remember to comment, rate, and VOTE!
Step 1: The Extensive Supplies List
- an Arduino (or really any microcontroller that can use the Arduino IDE's language)
- a piezo element or speaker capable of high frequencies in the 14-20kHz range
You'll also need a computer running Arduino IDE 18, a cable to interface between the computer and microcontroller (USB in many cases), and an external power source for the microcontroller (I use a 9V battery). Inconspicuous enclosure optional.
Step 2: Can We Build It?
Alright, so at this point we need to plug the speaker into one of the Arduino's digital I/O pins and ground. In my code, I have selected pin 13 for the (+) lead, but if you have something against that number (superstitious?), then go ahead and plug it in somewhere else. Actually, plug it in elsewhere if you want the sound to be louder, because pin 13 has a 1k-ohm resistor built in. After plugging in to the digital pin, plug the (-) lead of the speaker into one of the GND pins on your board.
Hooray, you've succeeded at winning the mission!
Wait, not so fast. We still need to upload code...
(Props to Fritzing for the sweet diagram below)
Step 3: Code Time!
Please note: The "Tone" feature is a new addition to Arduino 18, so if you don't have it, you'll need to download it from arduino.cc, or work your way around this issue.
The code is as follows, and you should be able to copy and paste it straight into the Arduino IDE...
long randNumber; //establishes randNumber
long randNumber1; //establishes randNumber1
void setup ()
void loop ()
randNumber = random(500, 3000); //randNumber is between .5 and 3 seconds
tone(13, 18000); //plays a 18kHz tone on digital I/O pin 13
delay(randNumber); //continues to play tone to the time of randNumber
noTone(13); //stops playing tone on pin 13
randNumber1 = random(10000, 30000); //randNumber1 is between 10 and 30 seconds
delay(randNumber1); //continues silence to the time of randNumber1
Step 4: Let Madness Ensue!
Next it's time to find a comfy and secret place for your creation. Consider your surroundings. Be aware that this will probably not work anywhere where it is loud because nobody will be paying attention anyway. No matter where you are, under a desk is always a pretty good bet, but if anybody looks under the desk, don't expect them to ignore the circuit board with blinking lights and a speaker. Hiding it in something "analog" (i.e. not a digital electronic) is probably better because, well, it's unexpected.