Introduction: Arduino Ticking Time Bomb

About: Interested in electronics and mechanical.
While fooling around with my arduino, I was inspired to make a ticking time bomb like one in movies and cartoons. When a switch is flipped, it counts down from ten on a LED display, beeps at an increasing pace, and lights an electrical igniter or incandescent light when it reaches zero.

This device is intended for theatrical and entertainment purposes only! Do NOT use this for evil.

Step 1: Materials

You will need:

-A two digit LED display
-8 220 ohm resistors
-1 68 ohm resistor
-1 100 ohm resistor
-2N3906 transistor
-TIP31 transistor
-20 male pin headers(optional)
-SPDT toggle switch
-Bolts & nuts/banana jacks/binding posts(you decide, I'll discuss this later)
-A tone buzzer
-A low voltage electrical igniter(optional)
-Perf board
-5 x 2.5 x 2 project box(optional)
-An Arduino
-Power supply for Arduino
-22 gauge hookup wire

The total cost comes to around $8 or $13, depending on whether or not you use the project box.

Also, this design is only capable of lighting a very low power electrical igniter or light. If you want anything that uses more power, you will have to use an external power supply.

Step 2: Testing

If you have ordered the LED display that I did, it should have the same pinout. C1 is the common anode pin for the left digit, and C2 is the common anode pin for the right digit. When positive is connected to pin C1 and negative to pin 1, LED 1 on the LED display would light up. You should make sure that each pin lights the correct LED before proceeding. When testing the device, remember that this display is designed to use 2.2 volts. I used a two AA batteries and a 68 ohm resistor for testing.

Step 3: Build the Circuit

Before soldering the circuit on perf board, you should test it on a breadboard to ensure that everything is connected properly. The code for the Arduino is on the next step.

Cut your perfboard with a dremel or hacksaw so that it fits inside your project box. Begin soldering the circuit onto perfboard once you have tested it on a breadboard. I chose to add male headers to my perfboard so I can plug the board into the Arduino rather than plugging the wires into the Arduino. I think it makes a much neater project in general. The layout of the circuit is left up to you, but I have left a few pictures of my layout if you need some inspiration. Also, if you do choose to use male headers, ensure that the components don't block the Arduino from plugging into your circuit. If you are unsure about this, or anything else, refer to the pictures.

The breadboard test:



A test of the soldered circuit:


Step 4: Build the Enclosure

I used a 5" x 2.5" x 2" project box for my enclosure. I drilled three holes on one of the sides - two for the bolts that held the incandescent light, and one to power the Arduino. Please note that there is no need to use bolts for the light - you could use binding posts, banana jacks, or anything else that you think would work well. I drilled a hole for the switch on the top, and I cut a rectangle out for the LED display with my dremel. You will have to select the drill bit sizes based on what components you use.

I used hot glue to secure the LED display, and used the nut that came with the switch to secure it to the top. I also tightened the bolts on to the side of the enclosure. When I finished, I plugged a power supply into the Arduino, and plugged the circuit board into the Arduino. Once all four screws were in, I was finished with the build.

Step 5: Code

This is the code that you will have to upload to your Arduino. Before you upload, make sure to disconnect all wires from the Arduino's digital pins 0 and 1. The Arduino uses these pins for communication with the computer, and if they are connected to anything, your upload will fail.

Code:

int oneLed = 0; //pin for the leftmost LEDs
int led1 = 1;   //pin numbers for LEDs on the righthand display
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int light = 19; //pin for the light/electrical igniter 
int beep = 16; //pin for buzzer
int switchPin = 14; //pin for switch input
int switchState = 0; //variable for storing the state of the switch

void setup( ) {

  pinMode(light, OUTPUT);
  pinMode(oneLed, OUTPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(light, OUTPUT);
  pinMode(beep, OUTPUT);
  pinMode(switchPin, INPUT);
}

void loop( ) {

switchState = digitalRead(switchPin); //read the state of the switch

//if the switch is on, go

if (switchState == HIGH) {

//write LEDs to display the number 10

digitalWrite(light, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
digitalWrite(oneLed, LOW);
digitalWrite(beep, LOW);

//beep on for 500 ms and off for 500 ms

delay(500);

digitalWrite(beep, HIGH);

delay(500);

//write LEDs to display the number 9

digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, LOW);
digitalWrite(oneLed, HIGH);

//beep for 250 ms, off for 250 ms, repeat twice

for(int i = 0; i < 3; i++) {
  digitalWrite(beep, LOW);
  delay(250);
  digitalWrite(beep, HIGH);
  delay(250);
}

//write LEDs to display the number 8

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);

//beep for 167 ms, off for 167 ms, repeat three times

for(int i = 0; i < 4; i++){
  digitalWrite(beep, LOW);
  delay(167);
  digitalWrite(beep, HIGH);
  delay(167);
}

//write LEDs to display the number 7

digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);

//beep for 125 ms, off for 125 ms, repeat four times

for(int i = 0; i < 5; i++){
  digitalWrite(beep, LOW);
  delay(125);
  digitalWrite(beep, HIGH);
  delay(125);
}

//write LEDs to display the number 6

digitalWrite(led1, LOW);
digitalWrite(led3, HIGH);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);

//beep for 100 ms, off for 100 ms, repeat five times

for(int i = 0; i < 6; i++){
  digitalWrite(beep, LOW);
  delay(100);
  digitalWrite(beep, HIGH);
  delay(100);
}

//write LEDs to display the number 5

digitalWrite(led4, HIGH);
digitalWrite(led7, LOW);

//beep for 83 ms, off for 83 ms, repeat six times

for(int i = 0; i < 7; i++){
  digitalWrite(beep, LOW);
  delay(83);
  digitalWrite(beep, HIGH);
  delay(83);
}

//write LEDs to display the number 4

digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led5, HIGH);

//beep for 62 ms, off for 62 ms, repeat eight times

for(int i = 0; i < 9; i++){
  digitalWrite(beep, LOW);
  delay(62);
  digitalWrite(beep, HIGH);
  delay(62);
}

//write LEDs to display the number 3

digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led5, LOW);

//beep for 50 ms, off for 50 ms, repeat ten times

for(int i = 0; i < 11; i++){
  digitalWrite(beep, LOW);
  delay(50);
  digitalWrite(beep, HIGH);
  delay(50);
}

//write LEDs to display the number 2

digitalWrite(led4, LOW);
digitalWrite(led7, HIGH);

//beep for 42 ms, off for 42 ms, repeat 12 times

for(int i = 0; i < 13; i++){
  digitalWrite(beep, LOW);
  delay(42);
  digitalWrite(beep, HIGH);
  delay(42);
}

//write LEDs to display the number 1

digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);

//beep for 33 ms, off for 33 ms, repeat 14 times

for(int i = 0; i < 16; i++){
  digitalWrite(beep, LOW);
  delay(33);
  digitalWrite(beep, HIGH);
  delay(33);
}

//write LEDs to display the number 0, turn the buzzer and light/electrical igniter on

digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led5, LOW);
digitalWrite(led7, LOW);
digitalWrite(beep, LOW);
digitalWrite(light, LOW);

delay(1000);

//turn the buzzer and light/electrical igniter off

digitalWrite(beep, HIGH);
digitalWrite(light, HIGH);

delay(9000);
} else {

//if the switch isn't on, turn everything off

digitalWrite(light, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(oneLed, HIGH);
digitalWrite(beep, HIGH);
}
}

Step 6: Use It!

You Ticking Time Bomb is ready for use. I built this for use as a prop, but it can be used in many other ways. Those ways do not include violence or evil. Please use this responsibly.