Why do I get the following output.
unsigned long foo, bar;
void setup()
{
Serial.begin(115200);
delay(5000);
foo = millis();
Serial.println(foo);
bar = millis();
Serial.println(bar);
}
void loop()
{
// put your main code here, to run repeatedly:
}
Output
4999
5000
Firstly shouldnt the first value of the output be at least 5000 if there is a 5s delay before it. Also
shoulnt a line or several lines of code be executed faster than 1ms?
Also when testing longs I sometimes have the following random problem,
startOfMotorR: 1258291200
startOfMotorR: 1258291200
startOfMotorL: 5008
startOfMotorL: 5009
startOfMotorL: 5009
where it should look like,
startOfMotorL: 5008
startOfMotorL: 5008
startOfMotorL: 5009
startOfMotorR: 5009
startOfMotorL: 5009
startOfMotorR: 5009
eg. I m trying to record the start time of two motors and the unsigned longs are acting kind of funny. The full code is lengthy but Im simply just doing something similar in the example of just calling the millis function when i detect the encoders for the motors.