Missing pulses!

Cord is being pulled out, 'A' comes we add 2cm on the result variable

Does not match what your code suggests.float k=0.0025;