# 2 7-SEG-ULN2803-BUTTON > 00-99 COUNTER

I have 2 7-seg, 1 ULN2803, 1 Button and Arduino Due or Uno
I need 0-99 counter with parallel connect 2 7-segment display but it's important they connect parallel each one. I'm pushing button every time and then they're count like this; 01-02-03-04-...-99
I have 0-9 counter code but it's hard to make compatible with 00-99 counter.

Have 2 variables, onesCount and tensCount.
In the code:

``````onesCount = onesCount +1;
if (onesCount == 10){
onesCount = 0;
tensCount = tensCount +1;
if (tensCount == 0){
tensCount = 0;
}
}
``````

Then send the two digits to the shift registers.

Then send the two digits to the shift registers.

Hi Bob, the OP did not say they have any shift registers.

@EknCn, can you give us the part number from your 7 seg display? It is not clear to us if it is a single or dual digit, common anode or cathode. If you are using uln chip, hopefully it is/they are common cathode.

Oops. Had another post in mind I guess.
In that case, yes, need to know if its common anode - in which case one needs 2 PNP transistors to control the anode of the selected digit, and then the ULN2803 sinking current thru the paralled cathodes for each segment with a current limit resistor.
If common cathode, need to drive the paralleled anodes for each segment with current limit resistors and use the ULN2803 to sink current from the common cathode for each digit.

PaulRB:
Hi Bob, the OP did not say they have any shift registers.

@EknCn, can you give us the part number from your 7 seg display? It is not clear to us if it is a single or dual digit, common anode or cathode. If you are using uln chip, hopefully it is/they are common cathode.

Oops. Had another post in mind I guess.
In that case, yes, need to know if its common anode - in which case one needs 2 PNP transistors to control the anode of the selected digit, and then the ULN2803 sinking current thru the paralled cathodes for each segment with a current limit resistor.
If common cathode, need to drive the paralleled anodes for each segment with current limit resistors and use the ULN2803 to sink current from the common cathode for each digit.

Hi, thanks for helping anyway i'm using common cathode 1 digit 2 7-seg display. It's my breadboard photo;

It's my connection type, if it's true i need way to write code...

PaulRB:

http://i.hizliresim.com/njJlER.jpg here's my draw. And my code i need cover this 00-99 counter.

Sayici means: Counter
Goster means: Show

``````int a=2;
int b=3;
int c=4;
int d=5;
int e=6;
int f=7;
int g=8;
int dp=9;
int kb=10;
int kon=11;
int but=12;
int sayici=0;
void goster(int n)
{
switch (n)

{ case 0:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
break;

case 1:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;

case 2:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
break;

case 3:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
break;

case 4:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 5:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 6:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 7:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;

case 8:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 9:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 10:
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 11:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 12:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
break;

case 13:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
break;

case 14:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

case 15:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;

}

}
void setup() {
// put your setup code here, to run once:
for(int i=2;i<12;i++)
{ pinMode(i,OUTPUT);
}
pinMode(but,INPUT_PULLUP);

}

void loop() {
// put your main code here, to run repeatedly:

goster(sayici);

{ delay(350);

{
sayici++;
}

}
if(sayici==9)
sayici=0;
``````

Please learn to post picture and code correctly! Read here especially points 7, 8 & 9.

Also there is something missing from the end of your code. Please edit your post, put in code tags and the missing code.

There are some mistakes in your schematic. Your displays have 2 pins both marked "3" and 2 pins marked "8". Also you show connections from the display to the Ardunino ground. This is incorrect and will prevent the multiplexing from working. Did you connect your circuit like that?

PaulRB:
Please learn to post picture and code correctly! Read here especially points 7, 8 & 9.

Also there is something missing from the end of your code. Please edit your post, put in code tags and the missing code.

There are some mistakes in your schematic. Your displays have 2 pins both marked "3" and 2 pins marked "8". Also you show connections from the display to the Ardunino ground. This is incorrect and will prevent the multiplexing from working. Did you connect your circuit like that?

Sorry for this i'm editting, yes i'm connect like this, it's common cathode and parallel connects. We need like this connect... thanks for Helping PaulRB. :

OK, let me know when you have finished correcting the errors. (if you think you have corrected them all, please re-read my last post).