# count up to 9999 and back to 0

Hi
I have a sketch found in Arduino COOK BOOK page 349.
well he counts to 9999, word after 9999 very slow.
Now I’m working on for some time, to get it so, count up to 9999, and then back to 0.
whatever I try I can’t.
Someone who knows the solution??
the lcd display is 1602, I use the arduino UNO
the figures on display are double line displayed.
code i have

``````#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte glyphs[5][8] = {
{ B11111,B11111,B00000,B00000,B00000,B00000,B00000,B00000  } ,
{ B00000,B00000,B00000,B00000,B00000,B00000,B11111,B11111  } ,
{ B11111,B11111,B00000,B00000,B00000,B00000,B11111,B11111  } ,
{ B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111  } ,
{ B00000,B00000,B00000,B00000,B00000,B01110,B01110,B01110  } };
const int digitWidth = 3; // the width in characters of a big digit (excludes

//arrays  to index into custom characters that will comprise the big numbers
// digits 0 - 4                             0      1       2      3      4
const char bigDigitsTop[10][digitWidth]={ 3,0,3, 0,3,32, 2,2,3, 0,2,3, 3,1,3,
// digits 5-9                               5      6      7        8      9
3,2,2, 3,2,2, 0,0,3,   3,2,3, 3,2,3};
const char bigDigitsBot[10][ digitWidth]={ 3,1,3, 1,3,1,  3,1,1, 1,1,3, 32,32,3,
1,1,3, 3,1,3, 32,32,3, 3,1,3, 1,1,3};
char buffer[12]; // used to convert a number into a string
void setup ()
{
lcd.begin(16,2);
// create the custom glyphs
for(int i=0; i < 5; i++)
lcd.createChar(i, glyphs[i]);   // create the 5 custom glyphs
// show a countdown timer
for(int digit = 9; digit >= 0; digit--)
{
showDigit(digit, 2);  // show the digit
delay(1000);
}
lcd.clear();
}
void loop ()
{
// now show the number of seconds since the sketch started
int number = millis() / 1000;
showNumber( number, 0);
delay(1000);
}
void showDigit(int digit, int position)
{
lcd.setCursor(position * (digitWidth + 1), 0);
for(int i=0; i < digitWidth; i++)
lcd.print(bigDigitsTop[digit][i]);
lcd.setCursor(position * (digitWidth + 1), 1);
for(int i=0; i < digitWidth; i++)
lcd.print(bigDigitsBot[digit][i]);
}
void showNumber(int value, int position)
{
int index; // index to the digit being printed, 0 is the leftmost digit
itoa(value, buffer, 10); // see Recipe 2.8 for more on using itoa
// dislay each digit in sequence
for(index = 0; index < 10; index++) // display up to ten digits
{
char c = buffer[index];
if( c == 0)  // check for null (not the same as '0')
return; // the end of string character is a null, see Chapter 2
c = c - 48; // convert ascii value to a numeric value  (see Recipe 2.9)
showDigit(c, position + index);
}
}
``````

Are you having a problem counting up to 9999 and back or in displaying it ?
The counting is easy

``````for (int x = 0; x < 10000; x++)
{
//code here to do what you want
}

for (int x = 9999; x >= 0; x--)
{
//code here to do what you want
}
``````

the original sketch for a 16.4 display I have a 16.2 display the sketch, which I gave france getting through, even after 9999. now I want him back 9999 in France to 0 It seems simple, but it is not (translator)

The automatic translation has done something horrible to your question and has made it unreadable and I cannot begin to imagine what you actually wrote.

What is your native language ? There may be a section of this forum where you can ask your question and receive replies in that language.

you have right,i have posted in NETHERLANDS section

SORRY

No problem.

C++ and using it with the Arduino is enough of a problem without us struggling with our two native languages trying to understand one another. Good luck and I hope that you get your project working.