# Help with counting from 0 to 99 with two separated displays

Hi, i am making a project about scoreboard for basketball, then I’m using two buttons decoders and two display. I have achieved increasing an decreasing point using the buttons but only from 0 to 9; i ont know how to make that when it pass nine to obviously ten make that display turn to zero and the other to one to continue with the increasing of the point. Also i wonder how can I reduce my code for showing the number I thought using multidimensional arrays but didnt work till now… thanks for the help

``````const int botonIncremento = 53;
const int botonDecremento = 52;
int tiempoBotonIncremento = 0;

void setup()
{
pinMode(53, INPUT);
for(int a = 0; a < 4; a++){
}

}

void loop()
{
//Incremento
{
delay(50);

{
}
}
}

//Decremento
{
delay(50);

{

}
}
}

{
case 0:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
break;

case 1:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, HIGH);
break;

case 2:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, HIGH);
digitalWrite(29, LOW);
break;

case 3:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
break;

case 4:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
break;

case 5:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, LOW);
digitalWrite(29, HIGH);
break;

case 6:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, HIGH);
digitalWrite(29, LOW);
break;

case 7:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
break;

case 8:
digitalWrite(26, HIGH);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
break;

case 9:
digitalWrite(26, HIGH);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, HIGH);
break;
}
}
``````

moderatore upfdate: added code tags (#button above smileys) and indentation (CTRL-T in IDE)

Hi, i am making a project about scoreboard for basketball, then I’m using two buttons decoders and two display. I have achieved increasing an decreasing point using the buttons but only from 0 to 9; i ont know how to make that when it pass nine to obviously ten make that display turn to zero and the other to one to continue with the increasing of the point. Also i wonder how can I reduce my code for showing the number I thought using multidimensional arrays but didnt work till now… thanks for the help

const int botonIncremento = 53;
const int botonDecremento = 52;
int tiempoBotonIncremento = 0;

void setup()
{
pinMode(53, INPUT);
for(int a = 0; a < 4; a++){

}

void loop()
{
//Incremento
{
delay(50);

{
}
}
}

//Decremento
{
delay(50);

{

}
}
}

{
case 0:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
break;

case 1:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, HIGH);
break;

case 2:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, HIGH);
digitalWrite(29, LOW);
break;

case 3:
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
break;

case 4:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
break;

case 5:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, LOW);
digitalWrite(29, HIGH);
break;

case 6:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, HIGH);
digitalWrite(29, LOW);
break;

case 7:
digitalWrite(26, LOW);
digitalWrite(27, HIGH);
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
break;

case 8:
digitalWrite(26, HIGH);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
break;

case 9:
digitalWrite(26, HIGH);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, HIGH);
break;
}
}

This isn't a very elegant solution but it should be simple if you need to keep the two digit values separate

``````int contador = 0;

////

{
}
}
``````

...R

the big switch can be written in a small function

``````void displayCount(int contador)
{
}
``````

you could extend that to

``````void displayCount(int contador, int display)
{
if (display == 0)
{
}
else
{
digitalWrite(36, contador & 0x08);  // pins as example
}
}
``````

Topics merged: please do not crosspost - that wastes time...

Robin2: This isn't a very elegant solution but it should be simple if you need to keep the two digit values separate

``````int contador = 0;
``````