HC-SR04 ultrasonic sensor + Arduino Mega = not working

Step 1, throw that code out.
Step 2, use the NewPing library (it includes sample code).
Step 3, make sure there's nothing in front of the sensor (wires or anything as the smallest thing can cause an echo).
Setp 4, enjoy!

If you run into problems, contact the author at the thread linked above. He's more than happy to help diagnose your problem.

Tim