Hi, I was just playing with my arduino uno r3 board.
I was using micros(); function.
At first, I wanted to see the time Serial.println("HI"); takes, then turned out that it varies alot!
From 5000us~8us!!!!
Then I started doing some experiments. For example, I gave delay(1); to the end of the code. Thinking that this wouldn't affect the time measurement because it is not between time measurement as you can see down here!!
Actually the first result is showing the affect of how many time you read the data(you'll see!)
-->>
void setup(){
Serial.begin(9600);//I set the baud rate to be 9600
}
int i=0;
unsigned long count1,count2=0;
void loop(){
for(int i=0;i<15;i++){//To test the result for 15 times!
count1=micros();
Serial.print("HI ");
Serial.print(micros()-count1);//This, prints the time interval
Serial.print(" ");
Serial.println(i);
delay(1);//This is where I gave a delay.
}
delay(100000);
}// END!!
================================================
Guess what??? the result was like this
HI 36 0
HI 36 1
HI 36 2
HI 36 3
HI 40 4
HI 32 5
HI 32 6
HI 2108 7
HI 2108 8
HI 2108 9
HI 2108 10
HI 2108 11
HI 2108 12
HI 2108 13
HI 2108 14
---> You can clearly see that the time interval increases dramatically(x50)!! from 8th reading...!
Also, when there is no delay~(under)
HI 36 0 HI 32 1 HI 32 2 HI 36 3 HI 40 4 HI 32 5 HI 2640 6 HI 3116 7 HI 3116 8 HI 3116 9 HI 3116 10 HI 3116 11 HI 3116 12 HI 3116 13 HI 3116 14=> Isn't that so interesting and confusing at the same time???
Sorry for such a messy post!! I'll conclude in 2 questions.
1.Why would time interval dramatically increase from certain point? Is it lag?? How is it possible?
2.Why would delay(1) almost exactly decrease the lagging time(?) by 1000???? How is it have an effect on it???
Thanks for reading my post, I'm a newbie so anyone who is watching this can write their thoughts and I'll be amazed...!!!
Looking forward for kind replys~
By the way, have a nice day, being happy is the best!! :D
From Junwoo HWANG(very confused :( )