Introduction: Easy Arduino Audio Annoyatron

Picture of Easy Arduino Audio Annoyatron

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

Picture of 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

Picture of 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. 

Step 3: Wiring

Picture of Wiring

Connect one wire of the speaker to pin 8 on the arduino, depending on your speaker you may have to solder breadboard wires to the ends of the speaker wires to allow them to fit into the arduino. Connect the other end of the speaker to gnd.

Connect the positive end of the L.E.D to analog 0 on the arduino (A0), You will almost defiantly need to solder wires to the led to get it to fit into the arduino. Connect the negative end of the led to gnd on the arduino. 

connect the battery and if you have already programmed it successfully, it should play a small melody when the lights go off. If it doesn't first make sure that you have waited 30 seconds. If it still doesn't work make sure the LED is the right way   around (switch which legs are connected to A0 and Gnd). If it still doesn't work change the if(light <=60){ value depending on the conditions (see step  2). If all that doesn't work make sure the battery has charge. And if that doesn't work ask in the comments section. 

The generated images are products of Frizzing


Step 4: Disguise IT!

Picture of Disguise IT!

I chose a tissue box to hide my annoyatron in, first poke a small hole that the led can sit in and be exposed to the outside light. Then place the rest of the hardware inside and pull a tissue out. The annoyatron can be hidden anywhere as long as the led is exposed to the light.  Have fun and be responsible with it, if you plan on putting it on a flammable material make sure everything is well insulated. 
I am not responsible for any damages caused to/or by this device us at your own risk. 

Comments

aaronXtreme (author)2014-01-27

your code didnt work....says note_g4...ect. is not declared help!

aaronXtreme (author)aaronXtreme2014-01-27

NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};

this

amandaghassaei (author)2012-09-14

nice project, you should post a schematic! who did you prank with this?

How do you recommend digitally doing a schematic, I know there are sites but I've never used any. I placed this in various bedrooms and in the basement while a movie was being played.

fritzing has a free, simple schematic editor. I also use eagle, but it's a little harder to get started with.

Thanks used it and posted the pics,

nice! makes it a lot easier to understand. thanks!

Thanks for showing me the software

About This Instructable

4,177views

10favorites

License:

Bio: Second year engineering student studying at the Beautiful Okanagan campus of The University of British Columbia. I like to tinker with electronics and meddeling with ... More »
Add instructable to: