Sunday 6 October 2013

Arduino Countdown Timer

main1.jpg
The Arduino Countdown Timer is a fun weekend project for beginners who wants to move on to something slightly more advanced. The timer controls two 7-segment displays which count down from 99 to 0, and can be stopped and started using a button. When the timer reaches 0, the display flashes and a buzzer beeps. This project is ideal for timing any life activity that happens in 99 seconds or less.

An interesting thing about this project is that the two displays collectively have 16 pins which are used, but the Arduino is able to control both using only 9 pins thanks to a technique called mulitplexing. This technique allows only one light to be on at any given time by connecting them together and then letting the Arduino control which display gets connected to ground. Even though only one light can be controlled at a time, thanks to the phenomenon of persistence of vision, if both lights are flickered on and off in series fast enough, we perceive them to both be on all the time. While this may seem complicated, this is actually a commonplace technique for controlling LED displays.

Get experimenting and see for yourself by building your own!

Step 1: Materials

1A.jpg
You will need:

(x1) Arduino Uno (Radioshack #276-128)
(x2) 7-segment display (Radioshack #276-075)
(x1) SPST momentary pushbutton switch (Radioshack #275-646)
(x1) M-type coaxial power plug (Radioshack #274-1569)
(x2) 220 ohm 1/4 watt resistor (Radioshack #271-1313)
(x1) 10K ohm 1/4 watt resistor (Radioshack #271-1335)
(x1) Grid-Style PC Board (Radioshack #276-149)
(x1) Piezo element (Radioshack #273-073)
(x1) 9v snap connector (Radioshack #270-324)
(x1) 9V Battery (Radioshack #23-853)
(x1) 5" x 2.5" x 2" project enclosure (Radioshack #270-1803)
(x1) 22awg solid core wire (Radioshack #278-1221)

Step 2: Attach the Display

2A.jpg
2B.jpg
2C.jpg
2D.jpg
Center the two 7-segment displays side by side on the PC Board. Hold them in place by soldering each of the display's corner pins.

Step 3: Resistors

4A.jpg
4B.jpg
Solder a 220 ohm resistor to the common cathode pin (pin 4) on the lefthand 7-segment display, and another 220 ohm resistor to the common cathode pin (pin 12) on the righthand 7-segment diplay.

Step 4: Solder Together

5A.jpg
Solder together all of the anode pins from one of the 7-segment displays, to the corresponding anode pins on the other 7-segment display.

For instance, pin 1 from the lefthand display should be connected to pin 1 from the righthand display. This process should be repeat for pins 2, 6, 7, 8, 13, and 14.

Step 5: Attach Wires

6A.jpg
6B.jpg
Attach a black wire to each of the end of the 220 ohm resistors not connected to the displays.

Solder a red wire to each individual pair of connected anode pins. There should be seven red wires in total.

Step 6:

7A.jpg
7B.jpg





7C.jpg




Place a piece of tape over the front of the 7-segment displays. Rub over them with a pencil until a solid outline appears.

Step 7: Tape

8A.jpg
Place the tracing centered upon the enclosure lid.

Step 8: Drill

9A.jpg
9B.jpg
Using a 1/8" drill bit, make holes in each of the inside corners of the tracing.

Step 9: Cut

10A.jpg
10B.jpg






10C.jpg




Insert the blade of a coping saw through one of the holes in the lid and use it to cut out the square outline.

Step 10: Clean

11A.jpg
11B.jpg
Remove the tape and file the edges of the square until the 7 segment display fits snugly.

Step 11: Battery Plug

12A.jpg
12B.jpg
12C.jpg








12D.jpg


Twist off the casing for the M-type plug and slide it onto the battery snap connector's wires.

Solder the red wire to the center terminal of the M-type plug and the black wire to the outer barrel terminals .

Twist the casing back onto the plug.

Step 12: Drill

13A.jpg
13B.jpg








13C.jpg





Drill a 1/8" pilot hole in the center of one of the 2" x 2.5" side of the enclosure.

Widen the pilot hole using a 1/2" spade bit.

Step 13: Wire

14A.jpg
14B.jpg
14C.jpg







14D.jpg




Solder a 10K ohm resistor to a 6" green wire, and then solder the other end of the resistor to one of the terminals of the pushbutton switch.

Next, solder a 6" green wire to the same terminal on the pushbutton switch as the resistor.

Finally, solder a 6" red wire to the opposite terminal of the pushbutton switch.

Step 14: Insert

15A.jpg
15B.jpg
Pass the pushbutton switch through the 1/2" hole in the enclosure and fasten it in place with its mounting nut.

Step 15: Program

16A.jpg
Program the Arduino with the following code:

Step 16: Wire it Up

17A.jpg
17B.jpg








17C.jpg




Plug the 7-segment display board into the Arduino as follows:

7 Segment<--->Arduino
   
anode pin 13<--->D2
anode pin 14<--->D3
anode pin 8<--->D4
anode pin 1<--->D5
anode pin 2<--->D6
anode pin 7<--->D7
anode pin 6<--->D8
cathode pin 12
(righthand display)
<--->D9
cathode pin 4
(lefthand display)
<--->D10

Step 17: Wire the Switch

18A.jpg
Insert the red wire from the switch into the 5V socket on the Arduino.

Insert the black wire into the ground socket on the Arduino

Connect the green wire to digital pin 12 on the Arduino.

Step 18: Wire the Alarm (optional)

19A.jpg
Connect the piezo's red wire to digital pin 11 on the Arduino.

Connect the piezo's black wire to one of the ground sockets on the Arduino..

Step 19: Plug In

21A.jpg
20B.jpg
20A.jpg







21B.jpg





Snap together the battery connector and the 9V battery, and plug the battery into the Arduino's power socket.

Step 20: Glue

22A.jpg
22D.jpg
22B.jpg22C.jpg


























Hot glue the circuit board to the inside of the lid such that the 7-segment display is sitting snugly in the square cutout.

Step 21: Case Closed

23A.jpg
23B.jpg
23C.jpg










Close the lid on the enclosure and fasten it shut with the included screws.

Step 22: How To Use

24A.jpg
To start the timer, press the button once.

To pause the timer, simply press the button again.

To restart the timer, press the button 3 times quickly in less than one second.

2 comments: