unsigned long timebegin; //as soon as you make the variable, the timer starts
// to make time a global variable, you must assign it a value
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
timebegin = millis();
}
void loop() {
// put your main code here, to run repeatedly:
delay(500);
unsigned long timenow = millis();
unsigned long duration = timenow - timebegin;
Serial.print("The duration is: ");
Serial.println(duration);
}
// what we have done here is measure the time of an
// action.