Abishai Singh

Smart Technology Solutions

2 7-Segment Display Using Arduino.

Hello people, today i am going to show you my resent project on which i have been working since  last night. It is driving 2 7-segment displays using arduino. The 7-segment display i used in my project is having 7 pins as to be connected on positive potential and one pin which is a common ground for them.

Driving 1 single 7-segment display is an easy task, but when you have to drive 2 or more of it than it becomes really complicated.

There are two way i which one can use many(more than 1) 7-segment display. The first method is to connect all the pins to the pins of micro-controller i.e each 7 pins to the pins of your micro-controller. And the second method is to make use of TDM i.e time division multiplexing. In TDM, we connect the 7 pins of the display with each other and then connect it to the micro-controller, but the ground of the displays are not connected directly but there is a transistor in between which could be turned on/off by the controller.Thus what ever is to be displayed is displayed by making use of time axis displaying digits one by one on the display, but the switching between the display is so fast that human eye can not see it.

Here i had used the 1st technique i.e i did not used TDM. I will show you the TDM technique in my preceding blogs.

So, the pin connection are shown in the figure.

The image shows which pin to connect with the arduino.

Remember to connect a 1K resistance at the ground pin of both the displays, as each LED in the display works on 3 volt and we have 5 volt supply from the arduino.

So, after connecting the hardware, which is easy, i will show you the code i have written for driving the displays.

The code which increase the count of the display form 00 to 99 is shown below:

/*
0 to 99.
This program was developed by Abishai Singh.
The program is made for driving 2 7-segment displays
& to display the no.s from 0 to 99 in increasing order.
It can be used as a timer counter by making a little modification in the program.
*/

int const a = 10;
int const b = 9;
int const c = 8;
int const d = 7;
int const e = 6;
int const f = 5;
int const g = 4;

int const p = A2;
int const q = A0;
int const r = A1;
int const s = 3;
int const t = 2;
int const u = A3;
int const v = 11;

int i;
int j;

int sir;
int ser;

void setup(){

pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(11, OUTPUT);
}

void loop(){

for (j=0; j<10; j++){
ser = j;

if(ser == 0){
digitalWrite (a, HIGH);
digitalWrite (b, HIGH);
digitalWrite (c, HIGH);
digitalWrite (d, LOW);
digitalWrite (e, HIGH);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);

}
else if(ser == 1){
digitalWrite (a, HIGH);
digitalWrite (b, LOW);
digitalWrite (c, LOW);
digitalWrite (d, LOW);
digitalWrite (e, LOW);
digitalWrite (f, LOW);
digitalWrite (g, HIGH);

}
else if(ser == 2){
digitalWrite (a, LOW);
digitalWrite (b, HIGH);
digitalWrite (c, HIGH);
digitalWrite (d, HIGH);
digitalWrite (e, LOW);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);

}
else if(ser == 3){
digitalWrite (a, HIGH);
digitalWrite (b, LOW);
digitalWrite (c, HIGH);
digitalWrite (d, HIGH);
digitalWrite (e, LOW);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);

}
else if(ser == 4){
digitalWrite (a, HIGH);
digitalWrite (b, LOW);
digitalWrite (c, LOW);
digitalWrite (d, HIGH);
digitalWrite (e, HIGH);
digitalWrite (f, LOW);
digitalWrite (g, HIGH);

}
else if(ser == 5){
digitalWrite (a, HIGH);
digitalWrite (b, LOW);
digitalWrite (c, HIGH);
digitalWrite (d, HIGH);
digitalWrite (e, HIGH);
digitalWrite (f, HIGH);
digitalWrite (g, LOW);

}
else if(ser == 6){
digitalWrite (a, HIGH);
digitalWrite (b, HIGH);
digitalWrite (c, HIGH);
digitalWrite (d, HIGH);
digitalWrite (e, HIGH);
digitalWrite (f, HIGH);
digitalWrite (g, LOW);

}
else if(ser == 7){
digitalWrite (a, HIGH);
digitalWrite (b, LOW);
digitalWrite (c, LOW);
digitalWrite (d, LOW);
digitalWrite (e, LOW);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);

}
else if(ser == 8){
digitalWrite (a, HIGH);
digitalWrite (b, HIGH);
digitalWrite (c, HIGH);
digitalWrite (d, HIGH);
digitalWrite (e, HIGH);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);

}
else if(ser == 9){
digitalWrite (a, HIGH);
digitalWrite (b, LOW);
digitalWrite (c, LOW);
digitalWrite (d, HIGH);
digitalWrite (e, HIGH);
digitalWrite (f, HIGH);
digitalWrite (g, HIGH);

}

for (i=0; i<10; i++){
sir = i;
if(sir == 0){
digitalWrite (p, HIGH);
digitalWrite (q, HIGH);
digitalWrite (r, HIGH);
digitalWrite (s, LOW);
digitalWrite (t, HIGH);
digitalWrite (u, HIGH);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 1){
digitalWrite (p, HIGH);
digitalWrite (q, LOW);
digitalWrite (r, LOW);
digitalWrite (s, LOW);
digitalWrite (t, LOW);
digitalWrite (u, LOW);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 2){
digitalWrite (p, LOW);
digitalWrite (q, HIGH);
digitalWrite (r, HIGH);
digitalWrite (s, HIGH);
digitalWrite (t, LOW);
digitalWrite (u, HIGH);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 3){
digitalWrite (p, HIGH);
digitalWrite (q, LOW);
digitalWrite (r, HIGH);
digitalWrite (s, HIGH);
digitalWrite (t, LOW);
digitalWrite (u, HIGH);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 4){
digitalWrite (p, HIGH);
digitalWrite (q, LOW);
digitalWrite (r, LOW);
digitalWrite (s, HIGH);
digitalWrite (t, HIGH);
digitalWrite (u, LOW);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 5){
digitalWrite (p, HIGH);
digitalWrite (q, LOW);
digitalWrite (r, HIGH);
digitalWrite (s, HIGH);
digitalWrite (t, HIGH);
digitalWrite (u, HIGH);
digitalWrite (v, LOW);
delay (1000);
}
else if(sir == 6){
digitalWrite (p, HIGH);
digitalWrite (q, HIGH);
digitalWrite (r, HIGH);
digitalWrite (s, HIGH);
digitalWrite (t, HIGH);
digitalWrite (u, HIGH);
digitalWrite (v, LOW);
delay (1000);
}
else if(sir == 7){
digitalWrite (p, HIGH);
digitalWrite (q, LOW);
digitalWrite (r, LOW);
digitalWrite (s, LOW);
digitalWrite (t, LOW);
digitalWrite (u, HIGH);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 8){
digitalWrite (p, HIGH);
digitalWrite (q, HIGH);
digitalWrite (r, HIGH);
digitalWrite (s, HIGH);
digitalWrite (t, HIGH);
digitalWrite (u, HIGH);
digitalWrite (v, HIGH);
delay (1000);
}
else if(sir == 9){
digitalWrite (p, HIGH);
digitalWrite (q, LOW);
digitalWrite (r, LOW);
digitalWrite (s, HIGH);
digitalWrite (t, HIGH);
digitalWrite (u, HIGH);
digitalWrite (v, HIGH);
delay (1000);
}
}
}
}

I hope you will like this. I made my own board which can be attached easily upon the arduino board. Some of its images are shown below:

I used a wero board for making the display board shown here.

I would also like to share some youtube links of my project:

&

Please comment on my work. Thank you.

Advertisements

18 comments on “2 7-Segment Display Using Arduino.

  1. Jeremy C
    June 2, 2012

    Very useful, Only issue is the amount of pins it uses up.

    • abishaisingh
      June 2, 2012

      Ya, you are right………….for controlling more number of display segments, we have to use time division multiplexing …………i will be using it for my project in near future.

      • Jeremy C
        June 2, 2012

        I tried that but I had quite a few issues with the draw rate (if there’s no latching). I suppose a capacitor could solve the problem however.

      • abishaisingh
        June 2, 2012

        Have you tried by making the the length of connecting wire shorter…….

      • Jeremy C
        June 2, 2012

        I did not, however it was only 6″. and in my project I’m also driving 7 7 segment displays, not 2.

      • abishaisingh
        June 2, 2012

        Well, when u are using 7 display units, you have to make the switching speed quite high……….Have you checked your program, if it is correct then it is the problem of latching………
        Why don’t you use a LCD monitor of 7×2, it would be easy to handle……

      • Jeremy C
        June 2, 2012

        It’s a score board for an air hockey table so they must all be separate displays.

      • abishaisingh
        June 2, 2012

        Yes, than its necessary…..
        If you have time problem than i suggest you the decoder circuits, these can be very useful…

      • Jeremy C
        June 2, 2012

        I’ve scraped that design entirely, I’m now using shift resistors with latching and have had no issues. Much more efficient I find.

      • sue
        February 12, 2014

        I try it and it works well….thanks.

  2. Cooking Hacks
    June 3, 2012

    Nice post and good work! Thanks for sharing

  3. Pingback: 2 7-Segment Display Using Arduino / Cooking Hacks Blog

  4. AZMI
    March 23, 2013

    hi.. just want know.. how to display on 7 Segment with the capital later. exmple A, B, C, D, E, F…………

    • Abishai
      March 23, 2013

      You should know the respective pin and the led in the 7 segment, and then through your program you can make the proper led’s glow to give the desired shape or alphabet or number.

      • AZMI
        March 24, 2013

        hi Mr.Abishai.. can i get your email..? here i cannot attach the 7 Segment pin..

  5. Afiq Kamalruzaman
    September 29, 2013

    hi,,thanks for the post..for my project,i need to add button before it count..can u tell me how to do in..thanks 🙂

    p/s: sorry about my poor english..

  6. pankaj
    September 14, 2016

    which 7 segment display have you use common anode or common cathode

Leave a Reply...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on June 2, 2012 by in Uncategorized.
Arduining

Physical Computing Mini-Projects

tronixstuff

fun and learning with electronics

Abishai Singh

Smart Technology Solutions

%d bloggers like this: