Ultrasonic sensor help

hey, I have been trying to interface the Ping))) ultrasonic sensor to my arduino for a few days now and
so far I haven't had any luck >:( here is my code, I hope someone can help out

#include <SoftwareSerial.h>

int Sig = 13;
int Pwr = 12;

void setup()
{
Serial.begin(9600);
Serial.println("Sonar detector");
pinMode(Pwr, OUTPUT);
}

int readSonar() {
  int readsignal = 0;
  int counttime = 0;

  pinMode(Sig, OUTPUT);
  digitalWrite(Sig, LOW);
  delayMicroseconds(2);
  digitalWrite(Sig, HIGH);
  delayMicroseconds(5);
  digitalWrite(Sig, LOW);

  pinMode(Sig, INPUT);

  readsignal = digitalRead(Sig);
  while(readsignal == LOW) {
    readsignal = digitalRead(Sig);
  }
  
  while(readsignal == HIGH) {
    readsignal = digitalRead(Sig);
    counttime += 1;
  }
  return counttime;
}

void loop()
{
  digitalWrite(Pwr, HIGH);
  int distance = 0;
  distance = readSonar();

  Serial.print("Value: ");
  Serial.println(distance);

  delay(100);
}

thats weird :-?. I just took out the range finder to put an led in between the power and ground signal and when I started to put the range finder back in, the active light kind if blinked. so I took it out, put it in more carefully and now it works. Finally! ;D