This analog IR distance sensor can be used to determine distance from the sensor to an object. You must either buy a distance sensor with the cable, or buy a separate 3 pin JST connector wire to use it. The red wire connects to 5V, the black wire connects to ground, and the white wire returns an analog voltage between 0 and 5V proportional to the distance measured. The Arduino’s ADC can be used to read and use this analog signal.
Note that there are different variants of this sensor available with different sensing ranging. Read the datasheet and purchase on that senses at the distance you care about for you project.
Download the Sharp IR Distance Sensor Datasheet (PDF)
Buy an IR Distance sensor with a cable from Amazon or Adafruit, or without a cable from Newark.