ultrasonic sensor abnormal

I use arduino mega 2560 board, I desired to blink the board led when distance measured is less than 10cm, using a simple hc-sr04 ultrasonic ping sensor,but the the led blinked continously although all connections were tight moreover this loop repeated even when ping was disconnected. I am attaching the snap of code with this, kindly help me fixing this. Note: I have also attached l293 motor driver circuit although not programmed their pins.

try the 'new' library (I cannot see anything wrong in your code) https://code.google.com/p/arduino-new-ping/downloads/list