HC-SR04 not working

hello!
my ultrasonic sensor is not working
the values it shows are:
172 cm
176 cm
Out of range
177 cm
Out of range
177 cm
178 cm
178 cm
Out of range
Out of range
Out of range
177 cm
Out of range
Out of range
Out of range
Out of range
Out of range
178 cm
Out of range
177 cm
Out of range
177 cm
Out of range
177 cm
177 cm
176 cm
177 cm
176 cm
176 cm
175 cm
175 cm
175 cm
176 cm
175 cm
176 cm
175 cm
176 cm
175 cm
175 cm
176 cm

nothingelse :confused: :frowning:

plz help me with this problem
the code i am using is:
#define trigPin 12
#define echoPin 13

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

if (distance >= 2000 ) {
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(500);
}
THANKS IN ADVANCE :slight_smile: