Ultrasonic Sensor to Arduino to Servo..

I was wondering if anyone would be able to point me in the right direction/ help me out.
Is it possible to program in arduino, to follow a moving object throught the use of ultrasonic sensor?

Most u/s sensors have a wide beam angle, so resolving the object may be difficult. I guess the answer as usual is "it depends" - on 1) size of object 2) direction of object relative to sensor 3) speed of object. 4) reflectivity of object to ultrasound. etc

You need to tell us what you want to do.

Good day sir!.. I have here an ultrasonic distance sensor(attached in a servo, moving left to right). It only calculates the distance perpendicular to it. I want the sensor to identify a moving object and follow it as it moves(servo).

please give me an idea on how to do it :)

It only calculates the distance perpendicular to it

Unfortunately, because of beam-spread, that probably isn't strictly true.

You still haven't answered to the question about how fast the object is moving - remember you're going to be limited by the servo sweep rate and the maximum sample rate of the rangefinder - usually only up to about 20Hz.

(attached in a servo, moving left to right).

At some point, you'll probably need to figure out the "moving right to left" bit.

As AWOL mentioned, not super easy to do with only 1 sonar. The usual method for tracking is to do some sort of "differential" measurement using 2 pickup sensors.

Typical U/S sonars have beams from about 40deg wide [Parallax Ping, Maxbotix EZ0] down to about 20deg wide [Maxbotix EZ4]. They will sense objects anywhere in the beam, not just perpendicular to the direction it's pointing.

If I wanted to do this, I might try using 2 sonars on the panning servo, with the beams aimed so there is a few degrees of overlap. Have to experiment to get the angle, based on the beam widths. Then, if the servo is not moving and an object moves into one of the beams, that sonar will fire and the other will not.

Then you can pan the servo over so both sonars are firing the same. Then as the object keeps moving, one sonar will stop firing, and you know which direction the object is moving, and you can pan the servo to follow it. This should work if the object isn't too far away and not moving too fast, as it will take roughly 200-msec to sample both sonars.

Something like that.