This simple device simple plays a small tune at a random interval, between 5 and 30 seconds when the lights in a room go off. It can be cleverly disguised inside a tissue box, or inside or under any number of household objects. This is a vary simple project (my first audio project) and requires vary few materials, most of which can be easily scavenged. If you are just starting with arduino or audio electronics and have the need/or want to prank someone, I would Recommend this project.
Step 1: Materials
For this you will need:
a small speaker (can be scavenged from most devices that make noise)
an led (can be scavenged from most electronic things that light up)
A 9v battery
a 9v battery to Arduino cable (link to make one yourself)
An arduino (most electronics stores will supply these, they are a bit costly, but you can build pretty much anything with it. If you don’t know what it is, imagine being able to program reality and you will know sort of what it does)
Arduino to usb cord (same as a basic printer to usb cable)
Wires(small solid core) or breadboard wires
soldering iron
solder
Third hand (recommended not necessary)
A computer with the arduino software installed
Access to the interwebs (I imagine your using that right now though)
A small amount of time and the willingness to learn a bit of code.
Know how to do basic soldering (if you don’t know this site has plenty of how-tos on the subject)
I would also recommend checking some basic arduino tutorials.
Step 2: Programming
The program I used was a variant of this one. Follow the steps on the arduino site so you can get the pitches.h library. Then paste this into the arduino software.
// annoyatron connect speaker to pin 8 and gnd
// led connected to anolag pin 0 and gnd
// makes noise when lights are off
#include “pitches.h”
int LED = 0;
int light = 0;
int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
int noteDurations[] = {
4, 8, 8,4,4,4,4,4};
void setup(){
pinMode(8,OUTPUT);
pinMode (LED, INPUT);
}
void loop() {
int light = analogRead(LED);
if (light <= 60){
int wait = random (5000,30000);
delay(wait);
for (int thisNote = 0; thisNote < 8; thisNote ++) {
int noteDuration = 1000/noteDurations[thisNote];
tone (8, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay (pauseBetweenNotes);
noTone(8);
}
} else {
noTone(8);
}
}
Then upload to your arduino board. If you have any questions about the code feel free to ask in the comments. In the if(light<= 60){
section the 60 may needed to be changed to a different number depending on how dark your room is. If it is not turning on when the lights are off increase sixty, if it is turning on all the time decrease sixty.
an led
A 9v battery
a 9v battery to Arduino cable
An arduino
For more detail: Easy Arduino Audio Annoyatron