Sharp IR sensor not working when clubbed with other code

Hello everyone..I am making an obstacle avoidance robot which uses a sharp ir sensor to detect the distance from an object and halts if the distance is less than 5cm..The sharp ir sensor is giving correct values on serial monitor when its individual code is run, however when the code is added to the code for motor halt and start the sensor starts giving values 0.00 for all distances on the serial monitor..PLZZ help..

You'll need to post that problematic code to get help. Use the # button above to wrap it in code tags to make it readable

If you're using GP2D12 or similar device, they don't measure properly at very short distances due to the foldover in their response characteristics at short distances.