Build this project with

The Amazing Annoyatron

Shop now
The Amazing Annoyatron is an award-winning tech kit that teaches kids how to code.

Parts & wiring

For this project, you’ll be delving into the world of the extra-terrestrial – or, at least, writing a program that makes it look like it. You’ll learn how to build some sweet sounds that could have come from a UFO or an alien spaceship. This is perfect for people easily freaked out by any mention of aliens or extremely boring teachers.

What you’ll need for this project

To build this project, you will be using the following components:

UNO R3 Board & USB Cable
UNO R3 Board & USB Cable
Buzzer
Piezo Buzzer

How to connect the parts

The wiring for this project is the same as in your first project, the ticking clock. All you need to do is slide the buzzer pins into the Arduino – the positive leg should go in PIN 11 and the negative leg should go in GND.

Hover over the PLUS signs for extra tips
This is the positive leg of the buzzer. It will have a ‘+’ sign on top of it and will also be longer than the other leg.
Don’t forget to plug the board into your computer with the included USB cable.

The final program

Here’s the code we’ll be using to program this invention.
int buzzer = 11;

int beepTone = 10; // The sound of the beeps
int beepLength = 5; // The length of the beeps

void setup() {
  // put your setup code here, to run once:
   pinMode(buzzer, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  tone(buzzer,random(1,beepTone * 1000),beepLength * 2);
  delay(beepLength * 2);
  tone(buzzer,random(1,beepTone * 1000),beepLength * 20);
  delay(beepLength * 20);
}

Make this more awesome

Learn how to modify the code

Change the sound of the beeps

Like in a lot of other projects we’ve built, you are able to change the sound of the beeping noises. Take a look on line 3 where we can make the beep pitch either higher or lower:

int beepTone = 10; // The sound of the beeps

Have a play around with this value and try to find the most annoying number. Note that any number over 32 will not work, but apart from that, have fun!

Change the length of each beep

At the moment, the ‘alien’ beeping is just a fast jumble of random tones. Fancy making this jumble more hectic? Want to slow it down just a notch? Line 4 is where you can change this and set exactly how long each beep goes for.

int beepLength = 5; // The length of the beeps

In the demo program, the beep length is set to 10. If we decrease this number, our beeps will get shorter and sound more jumbled. A good number to try to test this is 1. If we increase this number, our beeps will get longer and will sound less and less like alien signals – though still equally as annoying. Another good number to try is 25.

int beepDelay = 25; // The length of the beeps