auto increment loop not working

what is wrong with this? Output is just 0000000000000....

//counter variables for timers
int pumpCycle = 1;
int dayCycle = 0;
int nightCycle = 0;
int pumpClock = 0;

for (int timer = 0; timer < 15001; timer++)
{
if (timer/1000){
pumpClock = pumpClock++;

}
if (pumpClock < 12){
Serial.print(pumpClock);
}
else {
Serial.print(pumpClock);
}
if (pumpClock==16){
pumpClock =0;
timer=0;
}

}

This line:

pumpClock = pumpClock++;

is undefined. If you want to increment pumpClock, all you need is:

pumpClock++;

or

++pumpClock;

Either one is functionally identical to:

pumpClock = pumpClock + 1;

Regards,
Ray L.

It is not nice to update a for loop control variable in the for loop

timer=0;

This is rather odd. Under what circumstances do you think this if statement is/is not going to be true ?

if (timer/1000){
 . . . 
}

I like this format, makes it really clear what is going on:

pumpClock = pumpClock + 1;

6v6gt:
It is not nice to update a for loop control variable in the for loop

timer=0;

There is absolutely nothing wrong with updating the variable within the for loop, and there are many valid reasons for doing so. But, in this instance, it begs the question - Why not use a while or do loop instead, since the end condition of the for will likely never be true...

Regards,
Ray L.

6v6gt:
It is not nice to update a for loop control variable in the for loop

timer=0;

This is rather odd. Under what circumstances do you think this if statement is/is not going to be true ?

if (timer/1000){

. . .
}

This is my attempt to have a smaller clock variable to work with instead of having to worry about long numbers. 1200 is not divisable by 1000 without a remainder, but maybe the syntax is what I'm missing to be able to evaluate that properly.

setting timer back to 0 continues the loop. is this unnecessary code?

for (int timer = 0; timer < 15001; timer++)
{
if (timer/1000){
pumpClock++;
}
if (pumpClock < 12){
// Serial.print(pumpClock);
}
else {
// Serial.print(pumpClock);
}
if (pumpClock==16){
pumpClock =0;
timer=0;
}
Serial.print(timer);
Serial.println("");
}

the timer seems to be resetting at 1014, this is odd? any ideas as to why it would reset at 1014 and not

I was able to figure out the issue. researched and found that I needed to be using a modulus to determine if timer/100 had a remainder of 0 to auto-increment pumpClock.

midiean:
I was able to figure out the issue. researched and found that I needed to be using a modulus to determine if timer/100 had a remainder of 0 to auto-increment pumpClock.

Ah. That is what you attempted by ...

if (timer/1000){
 . . . 
}

You wanted ...

if ((timer/1000)*1000 == timer ){
 . . . 
}

Or

if (timer%1000 == 0){
 . . . 
}