6v6gt:
On detecting a pin's change in status, that is when the pin goes from HIGH to LOW or LOW to HIGH you have to have previously recorded the value of millis() in a variable so that on the next transition, you can calculate the elapsed time.
To detect a change in status, you also have to store the previous status in a variable.
My apologies, could you have another look at the code?