Programming error

AHaseeb:
what i want to print on the Serial port is the average distance of both cycles ...

This is the part I don't understand. I wonder if you are using the word "average" correctly?

Can you post a couple of example calculations.

...R