Arduino 7 Segment Countdown Timer

146,708

64

50

Posted

Introduction: Arduino 7 Segment Countdown Timer

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:

COMPONENTS:
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

TOOLS:
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!!!

THE CODE TIME!!! YAY!
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.

Share

    Recommendations

    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Spotless Contest

      Spotless Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    51 Comments

    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?