you'll have to take the time between two presses to calculate the differnce in Milliseconds.
so the first thing is to distinguish between the 1st and the 2nd press.
use a variable to count them.int numberOfButtonPresses = 0;
long int time_1;
long int time_2;long int time_difference; //thats what your looking for
now in your main loop wait for the action.
if (buttonPressed && numberOfButtonPresses== 0 ) { //first action
//maybe reset millis ... resetMilis();
//store the "start time"
time_1 = millis();
numberOfButtonPresses++;
}if (buttonPressed && numberOfButtonPresses== 1 ) { //SECOND action
//store the "end time"
time_2 = millis();
time_difference=time_2 - time_1;
numberOfButtonPresses=0; //reset button counter for the next time
}
HEllo,
Thank you very much, that's a big help.
Now i have an other question. I read that the millis() starts on startup. So on the first buttonPressed i need to reset the millis(), right?
But (sorry if this is a dump question) how do i reset the millis() and asign time_1 to the start time?
The same for time_2 and end time?
Is this also tru that you don't need an interrupt on overflow (because the millis() overflows on 9 hours .... )?
Thanks is advance.
regards
Ronald