void setup(){
Serial.begin(9600);
}
void loop(){
Serial.print("Time: ");
time=micros() - loop_timer;
loop_timer = micros();
Serial.println(time);
}
this is the code which i took from this website and edit it according to my requirement. The problem which i am facing is delay present in output.
i have attached the image of my output. In which initially, all 6 values come good according to delay in loop time. but after six values it jumps to 5 milli seconds then 12 and atlast 13 mili second till the end. my question is ..... is there a problem with my arduino or any thing else is going to happen to my arduino which i couldn't understand. plz help me for solving this mystery thank you.
Abdul rehman.
You're jamming characters into the serial line faster than they can go out. Once you get the serial buffer full, the Serial.print lines block until they clear enough space for the next print statement.
thank you for your answering Delta_G.
is there any solution to watch the actual values after some time?
you are saying that the time which is coming in the start of serial monitor is the true time?
Yes, those first few times before the serial buffer gets jammed up are the time it takes to turn over that loop. That is, the time to make two Serial prints and exit and reenter loop and do the two math steps and the two calls to micros. After that you are timing the serial comms.