A quick Annoyatron

I was playing with the “random” function, and ended up making an “Annoyatron”
(If that title is protected by Thinkgeek or others, I’ll rename it to Annoy-inator in honor of Doctor D. …Or maybe Annoyduino?)

A piezo buzzer is placed from ground to pin 11 on the uno (leg spacing fits directly) and that’s it.

The art is to make the pauses long enough, to keep people wondering what is beeping. And to make the beeps long enough to be noticed, but too short to help locating their origin.

The sketch can be used on an Attiny by commenting out all the serial communication and changing the pins.

Implementing power saving, could make it annoy for a very long time.

Strategy:

  • Wait (or go to sleep) for some time
  • Draw a randNumber to “stretch sleep time” to something useable, and make beeping random
    if n<1
  • Draw a randNumberFrq to define frequency (120 - 1500 Hz)
  • Draw a randNumberTime to define duration (50 - 500 ms)
  • Play a sound: tone(pin, randNumberFrq, randNumberTime)

Right now,
randNumber = random(60);
will give on average a beep per minute, it should be changed to
randNumber = random(600);
in practical use.

… unfortunately my position at work excludes me from harassing my colleagues.
:blush:

/* Annoyatron ver. 1
Peter_I February 2014


Strategy:
- Wait (or go to sleep) for some time
- Draw a randNumber ( to "stretch sleep time" to something useable)
if n<2
- Draw a randNumberFrq to define frequency (120 - 1500 Hz)
- Draw a randNumberTime to define duration (50 - 500 ms)
- Play a sound: tone(pin, randNumberFrq, randNumberTime)
else
- nothing/ go back to sleep
*/

long randNumber;
int randNumberFRQ;
int randNumberTIME;
int beepPin = 11;

void setup()
{
  Serial.begin(9600);
  pinMode (beepPin, OUTPUT);

  // if analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.
  randomSeed(analogRead(0));
}

void loop() {
  
  delay (1000); // or sleep
  
  // Generate a random number from 0 to "large enough" 
  // to give appropriate delay
  randNumber = random(60); //make this number larger to increase time between beeps
  Serial.println(randNumber); // see the number
  if (randNumber<1)
  {
  Serial.println ("wohoooooo");
  randNumberFRQ = random(120,1500);  // generate number for FRQ
  Serial.print ("randNumberFRQ = ");
  Serial.println (randNumberFRQ);
  randNumberTIME = random(50,500);  // and a number for duration
  Serial.print ("randNumberTIME = ");
  Serial.println (randNumberTIME);
  Serial.println ("**************************");
  Serial.println (" ");
  tone(beepPin, randNumberFRQ, randNumberTIME);  //BEEEEP!

}
  else
  Serial.println ("nope");
   Serial.println (" ");

}