But you may have many defferent delay() in your loop codes and you don't know how many milliseconds have been delayed anymore because it runs everytime differently. In this case you will need to use millis(). It's an internal clock in Arduino which starts to count time everytime the Arduino board starts running or is reseted. It can be counted to 50 days. To give the data of millis() to a variable you have to define this variable as unsigned long.
Code Example
unsigned long Val;
void setup(){
Serial.begin(9600);
}
void loop(){
Val = millis();
Serial.print("Count = "); Serial.println(Val);
delay(1000);
}
http://arduino.cc/en/Reference/Millis
No comments:
Post a Comment