You are on page 1of 16

ARDUINO

We care about your privacy COUNTDOWN TIMER


By randofo in Technology > Arduino 188,403 318 34 Featured
Your privacy is important to us, so please take a moment to indicate if we may collect and use your data. The
categories below describePublished
the typeOct.
of information
4, 2013 we gather about the Autodesk
Download applications and services
Favorite
you use and how you use them. This helps us customize your experience online and build better applications.
Find out more about the third-party services we use and our statement on privacy.

CHOOSE "YES"By
FOR ALL Randy Sarafan loves you!
randofo More by
Follow
the author:

CHOOSE "NO" FOR ALL

About: My name is Randy and I am a Community Manager in these here parts. In a previous life I had founded and run the
Instructables Design Studio (RIP) @ Autodesk's Pier 9 Technology Center. I'm also the author ... More About randofo »
Online experience

The Arduino Countdown Timer is a fun weekend project for beginners who wants to move
We
on want you to haveslightly
to something a good experience with us. To
more advanced. Thedotimer
this, we collect data
controls two about your online
7-segment behavior
displays or
which
attributes and use advanced data analysis so that we may deliver new versions of our sites with
count down
customized from 99 to 0, and can be stopped and started using a button. When the timer
content.
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.
Yes

An interesting thing about this project is that the two displays collectively have 16 pins
No
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
Communication
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
Your time is valuable. To ensure that our email communications, social media, and digital advertising are
phenomenon of persistence of vision, if both lights are flickered on and off in series fast
timely and relevant to you, we collect and analyze data about your actions on our site.
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.
Yes

Get experimenting and see for yourself by building your own!


No

 Add
Customer feedback
Tip V Ask Question | Comment Download

We welcome your feedback. To accurately collect your feedback and better understand your experience
with us, we may use feedback tabs, pop-up surveys, and data about how you use our products and sites.

Step 1: Materials
Yes

You will need:


No

(x1) Arduino Uno (Radioshack #276-128)


Digital advertising
(x2) 7-segment display (Radioshack #276-075)
(x1) SPST momentary pushbutton switch (Radioshack #275-646)
We strive to show you ads that are most relevant to you. To do this, we use services that provide ads
We strive to show you ads that are most relevant to you. To do this, we use services that provide ads
(x1) M-type coaxial power plug (Radioshack #274-1569)
based on your online interests and track their effectiveness. Sometimes, the most helpful and desirable
(x2)come
ads 220from
ohmmerging
1/4 watttheresistor
data that(Radioshack
we collect with#271-1313)
the data that our advertisers have collected from
you. However, we will never sell your personal data to third parties.
(x1) 10K ohm 1/4 watt resistor (Radioshack #271-1335)
(x1) Grid-Style PC Board (Radioshack #276-149)
(x1)
Yes Piezo element (Radioshack #273-073)
(x1) 9v snap connector (Radioshack #270-324)
No 9V Battery (Radioshack #23-853)
(x1)
(x1) 5" x 2.5" x 2" project enclosure (Radioshack #270-1803)
Troubleshooting
(x1) 22awg solid core wire (Radioshack #278-1221)

 Add
Sometimes, troubleshooting is necessary. To better understand your experience on our sites, we collect
data about your online behavior
Tip to identify
V Askand solve challenging
Question | Comment experiences and errors that you may
Download
encounter.

Yes
Step 2: Attach the Display
No

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.

 Add

Tip V Ask Question | Comment Download

Step 3: Resistors

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.

 Add

Tip V Ask Question | Comment Download

Step 4: Solder Together

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.

 Add

Tip V Ask Question | Comment Download

Step 5: Attach Wires

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.

 Add

Tip V Ask Question | Comment Download

Step 6:

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

 Add

Tip V Ask Question | Comment Download

Step 7: Tape

Place the tracing centered upon the enclosure lid.

 Add

Tip V Ask Question | Comment Download

Step 8: Drill
Using a 1/8" drill bit, make holes in each of the inside corners of the tracing.

 Add

Tip V Ask Question | Comment Download

Step 9: Cut

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

 Add

Tip V Ask Question | Comment Download

Step 10: Clean

Remove the tape and file the edges of the square until the 7 segment display fits snugly.

 Add

Tip V Ask Question | Comment Download

Step 11: Battery Plug

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.

 Add

Tip V Ask Question | Comment Download


Step 12: Drill

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.

 Add

Tip V Ask Question | Comment Download

Step 13: Wire

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.

 Add

Tip V Ask Question | Comment Download

Step 14: Insert

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

 Add

Tip V Ask Question | Comment Download

Step 15: Program

Program the Arduino with the following code:


/*

Arduino Countdown Timer


by Randy Sarafan - 2013

Uses two 7-segment displays to countdown from 99 to 0. When the


timer reaches zero, the display flashes and a piezo beeps.

- To start the timer press the button.

- To pause the timer, press the button again.

- To reset before reaching 0, press the button 3 times quickly in und


er 1-second. When timer reaches 0, press once to reset.
 Add
For more information visit:
Tip V Ask Question | Comment
https://www.instructables.com/id/Arduino-Countdown-Timer/ Download

This code incorporates Arduino State Change Detection and Debou


ncing example code by David A. Mellis, Limor Fried, and Tom Igoe.
Step 16: Wire It Up
This code is in the Public Domain.

*/ the 7-segment display board into the Arduino as follows:


Plug

<---
7 //
Segment Arduino
The number of>the pushbutton pin
const int buttonPin = 12;

// 7-segment identifier
<--- variables
anode
int leftnumber;
pin 13 D2
int rightnumber; >
<---
anode pin 14 for the current and the
// Variables D3 previous reading from the pushb
>
utton pin
int buttonState; <---
anode pin 8
int lastButtonState = 0; D4
>
<--- to keep track of the previous button press state
// Additional variable
anode
. pin 1 D5
>
// This one only keeps track of the state of the button when there is
a <---
anode pin 2 D6
// debounce delay > event.
int previousState;
<---
anode pin 7 D7
// Tracks the last>time the output pin was toggled
long lastDebounceTime = 0;
<---
anode pin 6 D8
// The debounce>time; increase if the button is registering a single
press more
cathode pin 12than once
long debounceDelay<--- = 20;
(righthand D9
>
// Variable for counting the number of times the button has been pre
display)
ssed.
int buttonPushCounter;
cathode pin 4 <---
(lefthand D10
>
display)

 Add

Tip V Ask Question | Comment Download

Step 17: Wire the Switch

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.

 Add

Tip V Ask Question | Comment Download

Step 18: Wire the Alarm (optional)

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

 Add

Tip V Ask Question | Comment Download

Step 19: Plug In

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

 Add

Tip V Ask Question | Comment Download


Step 20: Glue

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

 Add

Tip V Ask Question | Comment Download

Step 21: Case Closed

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

 Add

Tip V Ask Question | Comment Download

Step 22: How to Use

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.

 Add

Tip V Ask Question | Comment Download

Share

Did you make this project? Share it with us!

I Made It!

Recommendations
WiFi Paddle Boat.
by gzumwalt in Technology
DIY ACRYLIC INDIGO BUTTERFLY LAMP.
by Maggie Shah in Arduino
Arduino GoPro Wifi Control
by randofo in Arduino
Arduino Class
70,932 Enrolled

 Add Tip
V Ask Question

| Post Comment

We have a be nice policy.


Please be positive and constructive.

34 Discussions

Reply / Upvote
dancopy1 year ago

I would
like to take advantage of the same circuit for a countdown from 9999 to
0000 with Buzzer - what should be changed in the code? Thank you all

Reply / Upvote
JohnnyK261 year ago

i want tomake a 3 year countdown timer what can i change to acive that?

Reply / Upvote
micmac3 years ago on Introduction

I just completed a version of this. Mine is AC powered and is designed to count down in six minute
increments for six hours - it's for sleeping exactly six hours from the time you get in bed. It flashes an
LED and activates a buzzer when the counter hits 00.
I used a toggle switch instead of a button to avoid all the debouncing nonsense and because mine only
has two states - actively counting down or waiting to be activated. Thanks for the inspiration. When we
stand on the shoulders of giants, we can reach amazing heights.

1 reply F

Reply / Upvote
RussellB481 year ago

Hi, Could you please help me. I am very new to arduino. Just purchased an arduino leonardo several
weeks ago and have not been able to get a project up and running. I have been using codebender and
breadboards to prepare circuits. I love this project but am adding a relay to the buzzer trigger and need
to count down from 30 seconds. How do I modify program for 30 seconds.
Best Regards
Russell
Reply / Upvote
tarun laxkar2 years ago

how to make this 99 second timer to upto 99 minutes timer using same buttons and alarm.?
Please help

1 reply F

Reply / Upvote
rohank262 years ago

sir,in my project of smart sprinkler ,the sprinkler should automatically get on for a set duration(for ex- if
i set the timer on for 5-6 am everyday the sprinkler should get on automatically on the assigned
days.)So, can it be done using this project or i have to separately use a RTC (real time clock module
for arduino.)??

Reply / Upvote
sumitsmt3 years ago on Introduction

How can I modify the code to countdown from 99 min? and how to attache with relay????plz riply...

Reply / Upvote
amielv3 years ago on Step 15

how can i modify the code that countdown from 24? please help

Reply / Upvote
abu_seif14 years ago on Introduction

which language did you use for the programming part?

2 replies F

Reply / Upvote
diytransistor3 years ago on Step 15

How can I modify the code to countdown from 59? Also, nice 'ible. Thinking about making it.

Reply / Upvote
JánM33 years ago on Introduction

Great counter! And what I suposed to change in code if I want to countdown other time? Like 40
second and so on?

Reply / Upvote
steinie444 years ago on Introduction

Need an on/off switch or your battery will be dead in about 24 hours. At least turn off the LEDs and put
the Arduino to sleep when not in use.

Reply / Upvote
PunqRot4 years ago on Introduction

I understand your concern, but the RadioShack flyer specifically cites this Instructable and the web
page directs here.
They could have done a better job referencing the Radio Shack connection like, "this can be seen at
your local Radio Shack" or something to cite both sides.

Reply / Upvote
jsuptic4 years ago on Introduction

I wanted to leave a quick message about all the digitalWrite() commands that were done in the code.
There is a better way! I am in no way knocking how you did it, I just learned this way a couple days
ago. Arduino has what is called port manipulation (http://arduino.cc/en/Reference/PortManipulation).
What this allows is a single line to control digital pins 0-7 and another for 8-13. The command to write
is:
DDRD for 0-7 and DDRB for 8-13. For example:
DDRD = B10011011; //Set pins 0,1,3,4,7 to high and 2,5,6 to low.
The format is littleEndian meaning the right most bit is the 0 or 8 pin and left most bit is the 7 or 13.
By utilizing this technique two important actions happen. First: Each bit is set simultaneously, thus
saving clock cycles and eliminated any possible flicker (which would not be noticeable to human eyes
anyways). Second: In projects that deal with a lot of port/pin manipulation -- such as the one presented
here -- it can eliminate literally tens to hundreds of lines of code/copy and paste. As well it can
eliminate a lot of pin setup code since DDRD and DDRB are builtins
Once again I encourage everyone to read further on this, as I just learned it this week and as such
cannot fully explain it.
Also @ranofo, again great project! I am utilizing your wiring scheme to make a life counter/virtual dice
and had not thought of or understood multiplexing well before. Bravo Zulu for a job well done!
J.

Reply / Upvote
mmbasha4 years ago on Introduction

hello cqn you please help me with the codes of


a counter down timer of 10min and 59 sec which will be running on a seven segment led
with two button for (stop/resume) also one for reset
it will count down until it reaches 00:00 when it reaches zero it has to gives a buzzer sound for just
three second

Reply / Upvote
Asics4 years ago on Introduction

Thank you I had fun building this project. Nice directions and I'm nearing completion now. This is my
2nd instructable. I'm going to make the mystery book next!
More Comments Post Comment

Categories About Us Resources


Technology Food Who We Are Residency Program
Workshop Play Why Publish? Community
Craft Outside Jobs Sitemap
Home Costumes Contact Help
Find Us

CONTINUE TO SITE

Please choose "yes" or "no" for each


categoryInc.
© 2018 Autodesk, Terms of Service | Privacy Statement | Privacy settings | Legal Notices & Trademarks

You might also like