Arduino 7 Segment Countdown Timer




Introduction: Arduino 7 Segment Countdown Timer

About: I'm a software developer, but I also love tinkering with electronics. My Instructables are all about Arduino.
This project is based on a Kingbright dual 7 segment display and an Arduino Diecimila.
it counts down from 20 and lights up pin 13 LED when the timer is complete.
It uses no extra hardware which is usefull for low-cost projects.
It also features multiplexing to get the job done with only 9 pins altogether for the displays.

Step 1: Parts Needed

For this project you will need the following:

1. An Arduino (any kind will do)
2. A dual-7 segmant display or 2 seperate 7 segment displays.
3. 2 Resistors (the values depend on your display)
4. About 50cm of non-stranded wire

1. A soldering iron and solder. (My display was SMD so i had to solder wires to it for connection)
2. A fume extractor. (I really reccomend buying or making one as they are very helpful to you)
3. A wire stripper, or you could just use scissors

Step 2: What Is Multiplexing?

Multiplexing is when you control lots of LEDs with a few IO pins.
It is based on having to or more 7 segment displays and connecting them together, an example of what they would display is 00, 11, 22, 33, 44, 55, 66, 77, 88, 99.
But what we do in this case is control each GND (-) induvidualy which turns it into a multiplexed display.
We will switch displays every 0.5ms which gives us control of each display.

It is usefull when you are building a project with lots of components and are short of IO pins.

In this example, we will be controlling 2 7 segment displays with 9 IO pins.
If we don't use multiplexing, we will need 14 IO pins to control the whole thing.

Step 3: The Build

This project is quite complicated so you will need basic electronic skills.

First you will have to solder wires on the back to make the multiplexing circuit.
This can be done on a breadboard if your display is not SMD.

Secondy, solder on jumper wires to plug the display into the breadboard.

Thirdly, connect wires from the breadboard to the Arduino in this sequence:

Segment A: pin 7
Segment B: pin 8
Segment C: pin 4
Segment D: pin 3
Segment E: pin 2
Segment F: pin 6
Segment G: pin 5
Gnd1 via resistor: pin 11
Gnd2 via resistor: pin 9

Step 4: The Programming!!!

This is my favourite part of any project, because i know it is almost complete!

I have wrote 2 programs: one that counts down from 20, and another that scrolls the message"Arduino" across the displays.

I will explain some of it in the code, just so you can understand it a bit better.

In the beginning, it initialises all the pins, and sets a few variables.

In the Void Setup, it sets up all the pins as outputs.
It also contains lots of FOR LOOPS, which are used when the LEDs are switched.

In the Void Loop, it sets pin 13 high and fades the 2 gnd pins on and off, which displays a pulsing 00.



    • Metalworking Contest

      Metalworking Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    51 Discussions


    1 year ago

    how can i get a coding timer countdown using arduino ???

    what happen if add push button? Can you show the connection and its coding?

    This is good but Can you make a programmable countdown with 7 segment display ?

    Hi, I have a question.

    How is pins 9 & 11 providing GND or (-) for common cathode Seven Segment Display?

    I thought the outputs only supplied (+) outputs? Or has this have something to do with a potential difference across Seven Segment Display?

    hi, it worked very well for me, but I also need that the countig only happens while I am punshing a button (for my halo assult rifle replica) I am new in arduino so I really dont know how to do it, do you think that you could help me with it?

    (I am kinda desesperated, I have been looking for it for a long time and I dont understand to much how to do it, or I dont find it, please help :T )

    Now how do I add buttons for auto and select fire mode a la colonial marines pulse rifle? ;)

    Soo, I built it but mine are common anode (KINGBRIGHT SA52-11EWA). I pretty much reversed the entire code so that "(gnd1, B1);" activates that pin as a gnd-pin. The same for the pins; "(pin1, B0);" sets pin 1 HIGH.

    Also, in each for-loop I put the "gnd code lines" at the top. They seemed to affect the code under it and not above it. Now it works just fine :)
    Dont really know if this is a good or safe way of doing it but it works.

    Improvement hint: It looks like you used something like two 170 ohm resistors. Assuming this, you receive a (constant) current of about 17mA for one digit (@5V source and 2V forward voltage per LED). This current will be divided into 1 to 7 segments, depending on how many of them are turned on. That's why the number 1 illuminates much brighter than a 8 in your video. That's a really bad design for a 7-segment. Use 680 ohm resistor per segment (!) instead to receive equal brightness. You will get less than 5mA per segment, one µC digital pin can sink 40mA max. More brightness can be achieved with external open-collector circuitry and smaller resistors.

    didnt work for me, the downcounter. i'm using a kw2-502csb dual 7 segment, but the connections are more or less the same. just some random counter happens fast and after tht 00 is appearing with the fading effect. please do explain.

    sir is there a way to pause resume and reset the timer from running?

    hi i have built this timer and loaded the programme into my arduino but it just lights up the 7 segment display and then jumbles through a load of numbers really quickly. then it stops and starts pulsing. does anybody know why. please be simple, im new to arduino:)

    1 reply

    I know this is late but if anyone else has this issue hears what you need to do. When you open the code in the arduino program find anywhere in the code that says delay(0.5) ; and replace it with delay(1.0) ;

    Nicely done! May I ask, if I wanted to pause, or restart (both the use of two separate switches) how can I modify your code?

    Any chance you could update the code to have 8 digits displaying hours, minutes, seconds, milliseconds and colons (:) in between each?
    I have some coding experience with arduino and I'd be willing to help.

    1 reply

    Hello! Could you make library for this? I think it'l be very usefull.

    Would you be able to put a 10 key keyboard on this project to start and stop the timer with a code? My friends and I have airsoft guns and we all played Counter Strike as a kids.

    hi i need to use to seven segment displays and this is great but is it possible that they could write a int or value of a sensor if so please tell me and email me the code or just post it on a comment thanks

    ""hi i have built this timer and loaded the programme into my arduino but it just lights up the 7 segment display and then jumbles through a load of numbers really quickly. then it stops and starts pulsing. does anybody know why. please be simple, im new to arduino:)""

    I have the same Problem its to fast .... and its the same when i change it from delay(0,5) to delay(5) // int timer 100

    Please help