praveen_khm:
Yes. I have them printed and it is the problem with the logic. Kindly check the below and let me know if there is a better way to implement this.
Then post some examples of the inputs you get from pulseIn() and the corresponding calculated values that are incorrect.
Also post your complete program so we can see all the details. Usually the problem is in the piece that has not been posted (which is likely why you have not yet found it
)
...R