Ultrasonic Sensor prints only zeros!

Hi again!
I have a problem with my ultrasonic distance sensor.Although when I first bought it,it was working fine and was printing the distance with great accuracy, lately for some reason it wasn't corresponding.I thought it was a problem on my code so i uploaded a simple code for ultrasonic sensor and it worked.Then a few days later even that sketch wasn't working.The only thing that does is (if i tell him to print to the serial monitor the distance)to print 0 all the time!!!!!!And I am sure that it has nothing to do with my arduino because i uploaded the blink sketch and it's working as it supposed to be.Is something wrong with my sensor???Probably, but I need and a second oppinion.Thanks a lot!

What type of sensor?
How is it connected to the Arduino?
Can you check the soldering of the device, and your wiring?

It could also be broken e.g. due to unintended swapping of power lines ...

Yeah I forgot to say the type of sensor.I am using an HC-SR04 and Vcc goes to 5v,Gnd to ground (of course),and trigger goes to pin 10 and finally the echo goes to pin 3.
I do not think that it's got to do with the soldering because a few days ago worked fine.

It could also be broken e.g. due to unintended swapping of power lines ...

What exactly do you mean by that??

if you have swapped vcc and GND by accident?
I blew a nice serial LCD once by wrong connection, now it is just a nice backlight :frowning: :wink:

Oh i am sorry for your loss but i do not think it's that either.But just to be sure how can I check this out?

I am having the same issue, my connections are done correctly as per this post so VCC and GND are not swapped. But I still get 0 cm in the distance.

Below is my code:

#define trigPin 3
#define echoPin 2
#define digPin12 12

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

void loop(){
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration= pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  Serial.print(distance);
  Serial.println(" cm");
  digitalWrite(digPin12, HIGH);
  delay(500);
}

What happens if you reduce the trigger pulse time?
A millisecond sounds awfully long.
10 or 20 microseconds sounds to me more sensible - want does the data sheet say?