Parts & wiring

In this project you’ll be using the same parts as your first project to build an annoying countdown. Please note that as this sounds like the sort of bombs that you see in action movies, we highly discourage you from using this inside areas or other places where this could cause chaos or confusion. You proceed further with this project at your own risk.

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
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;

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

  for(int i = 1000; i > 10; i = i * 0.9){
    digitalWrite(buzzer, HIGH);
    digitalWrite(buzzer, LOW);

void loop() {
  // put your main code here, to run repeatedly:


Make this more awesome

Learn how to modify the code

Change the length of the beeps

The longer a beeping sound goes for, the more annoying it is. Really. So why not make the beeps in our program longer? Right now, each beep only goes for a measly 100 milliseconds – a tenth of a second. Surely we can do better than that.


Line 9 in the code controls the time, in milliseconds, in-between when the buzzer is turned on and when it is turned off. If we change this value to something like 500, then the beeps will go for half a second. What about to 750? Each beep will now go for three-quarters of a second. Now that’s more like it.


Change how long the beeping goes for

Take a look at the code on line 7. While it does look a bit complicated, this is the line of code we need to change if we want to control how long the noise bomb beeping goes on for before it stops.

for(int i = 1000; i > 10; i = i * 0.9){

The only bit of code you need to pay attention to is int i = 1000; which is at the very start of the line. This number controls the delay between beeps at the start of the program, which gradually decreases until there’s almost no delay at the end of the program. Like many of the other numbers we’ve been working with, this one is in milliseconds as well. Change it to 2000 and you will get a break of 2 seconds between beeps at the start of the program.