Trouble with HC-SR04

By the way, you should set the trigger to LOW first before setting it to HIGH. And you don't need 1000 microseconds. The spec says 10 microseconds will do. http://www.micropik.com/PDF/HCSR04.pdf

Try ch

void loop() {
  int duration, distance;
  digitalWrite(trigPin, LOW);  //  Added
  delayMicroseconds(2);          // added
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);        // changed to 10
....