Building your own Annoy-a-tron with an ATtiny85

The annoy-a-tron is a little device that makes a small beep every X minutes. If you hide it well enough in a co-worker’s cube, it will drive him/her insane and will do almost anything to find it.

The annoy-a-tron is currently out of stock at ThinkGeek and I really wanted to prank someone at the office with it. So I did some research and decided to build one.

I decided to go with the ATtiny85 because I enjoy coding more than I do soldering. Instead of buying a 555 timer chip with resistors, capacitors, etc. like they are doing here, I just need to program the chip, wire up a battery and a speaker. I chose the ATtiny85 over the Arduino hardware because the ATtiny is cheaper and draws less power.

The final product looks like this:

20150621_223628

And the software I put together makes a beep of customizeable tone frequency and length at random time intervals.

These are the parts you need to build the circuit:

The ATtiny85 is cheaper if you buy it in bigger quantities, I regret not buying more just so I can have different programs (different random intervals, tone, and tone length) loaded on the chips ready to go. SparkFun doesn’t have the best prices so look around if you will buy in bulk. I trust SparkFun and that’s why I bought most things there though.

You need a programming board to program the ATtiny85. I chose the Tiny AVS Programmer instead of the official one because I wanted to try out the Arduino IDE. To set up the IDE with the programmer, just follow the programmer’s hookup guide.

The Circuit:

The circuit is very straight forward. You just wire:

  • The positive end of the battery holder to the positive pin on the ATtiny85 (the solder tail).
  • The negative end of the battery holder to:
    • The negative pin on the ATtiny85
    • The negative pin on the piezo speaker
  • The chosen out pin (I chose pin 1) of the ATtiny85 to the positive end of the piezo speaker.

20150621_223603

The Program:

I used the Arduino IDE (set up with the Tiny AVR Programmer Hookup guide) to program the ATtiny85.

Click this link to get the source code of program I loaded on the ATtiny85.

The program was deeply inspired by TinyTone to generate the tones and millionOhms to preserve power by getting the ATtiny85 to go to sleep.

I found that testing the program out takes a long time since you have to actually wait and see how the chip behaves. The program works like I want it to but I still have some questions that I’d like to ask an Arduino IDE (c++) expert or need a good amount of time to test out:

  • are the #include statements optional?
  • are the #define statements actually setting a variable or are they optional?

Testing those things would take time since removing them might not make compilation break but it might make the ATtiny85 not go to sleep properly and use more battery than expected. So I would have to see how long the battery lasts to really know if it is sleeping properly or measure the current being used by the ATtiny85 with an ampmeter.

Well, I hope you have fun with the ATtiny85! I’ve tried it with a couple of beta victims and I’m ready for a real one tomorrow.

Advertisements

10 thoughts on “Building your own Annoy-a-tron with an ATtiny85

  1. Cool project. I’d like to build one myself as I’ve always wanted to get into hardware hacking and also because like you I found an off the shelf annoyatron was out of stock. Looks like they don’t carry that tiny protoboard any more but looks like PRT-13268 should be a suitable replacement. I was actually looking to get the parts from somewhere like digikey. The only thing I struggled with was finding an appropriate battery holder. There are like 30 of them that are thru hole 2032 holders, but how do I find one where I know the leads will fit the .1″ pitch of the prototype board?

    • Hey Brad,

      Most battery holders will fit the holes just fine. And when they don’t you can usually find a way to make it fit by rotating the battery holder, this will make it so you don’t use the holes in a straight line, but that is usually ok. And as a last resort you can get a little creative with using tons of soldering wire or soldering a real wire between two holes and soldering the battery holder to that wire… etc.

      Good luck and have fun!

    • Hi Gordon, the battery lasts at least a couple of months.

      On early stages of the code, the battery would drain out in 3 days, but that’s because I was not making the chip go to sleep. Once I figured out the sleep code it lasted months. The longest time I’ve seen it run has been for 2 months straight before it was found, the battery was still OK after that.

      The latest version of the code makes the chip go to sleep and you can find it here: https://github.com/pedroliska/ATtiny85/blob/master/watchdog-wake/watchdog-wake.ino

      • I’ve build the circuit and installed the code but can’t get it working. Any advice?

      • Hey Gordon, my best guess is the circuit has an error. If you email me a picture or a diagram I could double check the wiring for you. You email is my first name at pedroliska.com .

        It’s really cool that you made the circuit! I had a lot of fun with it.

  2. Hi Pedro,

    Is it possible to have the device sleep for an extended period of time before activating.
    ie, hide the device and some duration later (4 weeks?) it wakes up and starts working as you’ve currently programmed it.

    Alternatively – it would be neat if it could sleep for whole days at a time.

    Thanks !

    • Hey David. What you want is totally doable!

      You really just need to tweak my source code a bit. The key part is the parameter that you send to the goToSleep method in this line: https://github.com/pedroliska/ATtiny85/blob/master/watchdog-wake/watchdog-wake.ino#L40

      You can send it really big minute values (they have to be valid integers though) so the chip goes to sleep for days or months and then starts beepgin.

      The goToSleep method is optimized as much as possible to use the least amount of power. Well, at least to the best of my knowledge after reading the chip’s data sheet in detail and going through tons of sleep functions in the internet. The max the chip can sleep is really 8 seconds, but you can immediately put it to sleep again.

      As I type this I’m remembering that you can change the chip’s clock speed. If you slow it down, it would probably use less power and it could sleep longer. But it is possible that I have already slowed it down as much as possible so 8 seconds is the max sleep; but I can’t remember 😦

      Good luck!

  3. Hi Pedro,

    Very neat project! I tried entering the code in Arduino but I get errors when I try compiling it. I’m using Arduino 1.8.2. I’m not sure if there’s an error in the code?

    Thanks,
    Aaron

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s