Easy Arduino Audio Annoyatron

by Zaphod Beetlebrox in Circuits > Arduino

5501 Views, 11 Favorites, 0 Comments

Easy Arduino Audio Annoyatron

IMG_5008.JPG
IMG_5013.JPG
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. 

Materials

IMG_4989.JPG
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. 

Programming

programming.jpg
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. 

Wiring

Frizzing realview.jpg
IMG_4994 - Copy.JPG
IMG_4995 - Copy.JPG
IMG_5001 - Copy.JPG
IMG_5002.JPG
IMG_5006.JPG
IMG_5007.JPG
Frizzing schematic.jpg
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


Disguise IT!

IMG_5005 - Copy.JPG
IMG_5008.JPG
IMG_5011 - Copy.JPG
IMG_5012.JPG
IMG_5013 - Copy.JPG
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.