unsigned long oddity

Hi All,

I'm not the most brilliant Arduino programmer, and still getting to grips with a lot of the code.
Been playing with the millis() function.

I have two variables configured as unsigned long

unsigned long PreFlowDelayMs = 0;
unsigned long currPreFlowMs = millis();

Part of my code which is in a timing loop is supposed to take the value of currPreFlowMs and essentially assign that value to PreFlowDelayMs .

As in the section of code.

PreFlowDelayMs = currPreFlowMs;

Tracing the code, I note that the value of currPreFlowMs is never assigned to PreFlowDelayMs .

Before I post a lot of code, maybe someone has come across this and has an answer.

Thanx.

Just post the code.

Are you perhaps somehow imagining that currPreFlowMs somehow gets magically updated each time mullis changes? It does not. You have to explicitly update it whenever necessary.

Or maybe you've got a scope issue.
Post. The. Code.

PreFlowDelayMs = currPreFlowMs;
Tracing the code, I note that the value of currPreFlowMs is never assigned to PreFlowDelayMs .

Really? Try examining it immediately afterwards:

PreFlowDelayMs = currPreFlowMs;
Serial.println(PreFlowDelayMs);
Serial.println(currPreFlowMs);

If neither values gets printed, you just messed up somewhere and your code skips the lines entirely.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.