Dear community,
I need a counter that counts from 0 to 300000. As Display I want to use an 2x16 LCD display. The code from Tomek for an LCD display with 4 DataPins works quiet well. The only problem I have, is that I can only display a max. number: 999

These lines do the meta work in the code:

// this funktion help us to write number over 9, easyely in the lcd display
void LcdNumberWrite(int nr) {
int n1 = 0;
int n2 = 0;
n1 = n2 = nr;
n1 = n1 / 100;
LcdCommandWrite(560 + n1); //512 used to wirte data (see commands for character modul)
n2 = (n2 - n1 * 100) / 10;
LcdCommandWrite(560 + n2); //512 used to wirte data (see commands for character modul)
nr = nr - n1 *100 - n2 * 10;
LcdCommandWrite(560 + nr); //512 used to wirte data (see commands for character modul)
}

Can anybody give me a tip, how I could display big numbers like 300000 ??

This code simply works out how many hundreds you have then outputs that. Then it subtracts the hundreds and works out how many tens you have and outputs that number. Finally how many units and displays that. What you need to do is to extend this to the size of number you need.

However you will then be faced with the problem that the int variable type can't handle numbers this large and floating point numbers don't have the precession so you will have to go to multi variable arithmetic. That means using one int variable (maybe in an array) to specify each digit you want and writing routines to increment and decrement it.

If I posted you the code I would be denying you the pleasure of working it out, whats more you would learn absolutely nothing, like you have from the example code you already have.

OK I think the way you have it is a bit messy so see if you can understand this:-

you have a number say it’s 1234 in a variable called N.
If you do Display1 = N / 1000
Then the result Display1 will be equal to 1
Next you have to separate out the hundreds there are a few ways of doing this. One way would be to subtract what you have already separated so that:-
N = N - (Display1 * 1000)
at this point N will have a value of 234 so repeat this method

Display2 = N / 100

Then the result Display2 will be equal to 2 and do :-
N = N - (Display2 * 100)
at this point N will have a value of 34 so repeat this method

Next separate out the 10s
Display3 = N / 10
Then the result Display3 will be equal to 3 and do do it again for units
N = N - (Display3 * 10)
Display4 = N

The trick here is that because you have intergers all the remainders disapere and you chip away at the number.

One last thing (for extra credit) as what you are doing each time is so much the same see if you can re write it as a loop.

Dear Grumpy,
sorry, for not sending a feedback to you. I was on holidays - but finally got the code running.- AND thanks one mor time for your help!!!

Here is the part of the modified Tomek-Code:

// this funktion help us to write number over 9, easyely in the lcd display
void LcdNumberWrite(long N) {
long display1 = 0;
long display2 = 0;
long display3 = 0;
long display4 = 0;
long display1a = 0;
long display1b = 0;
long display1c = 0;
//display1 = display2 = display 3 = display4 = N;

display1c = (N/1000000);
N = N - (display1c * 1000000);
LcdCommandWrite(560 + display1c); //512 used to wirte data

display1b = (N/100000);
N = N - (display1b * 100000);
LcdCommandWrite(560 + display1b); //512 used to wirte data

display1a = (N/10000);
N = N - (display1a * 10000);
LcdCommandWrite(560 + display1a); //512 used to wirte data

display1 = (N/1000);
N = N - (display1 * 1000);
LcdCommandWrite(560 + display1); //512 used to wirte data

display2 = (N/100);
N = N - (display2 * 100);
LcdCommandWrite(560 + display2); //512 used to wirte data

display3 = (N/10);
N = N - (display3 * 10);
LcdCommandWrite(560 + display3); //512 used to wirte data

display4 = N;
LcdCommandWrite(560 + display4); //512 used to wirte data