measuring time

Hi everybody!

I'm almost new in Arduino and I'm trying to send a sample of an Ultrasonic (HC-SR04) sensor to PC over Bluetooth. The main problem is that time the pulseIn function I am using to work out the distance depends on the distance. I mean, the more distance, the more time it takes.

Any idea of how I can set the sampling time? I don't mind if it's not too quick because I will interpolate the signal in matlab.

I have tried using millis() but it doesn't work.

Thanks