> For the complete documentation index, see [llms.txt](https://wiki.purduesigbots.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.purduesigbots.com/vex-electronics/vex-sensors/smart-port-sensors/distance.md).

# Distance Sensor

The VEX V5 Distance Sensor measures the distance between the sensor and an object using a small laser.

## V5 Distance Sensor

![](https://3510336827-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7yGVyBrcpSR8SDSikj%2Fuploads%2F0zY99qs3wqFTvw1W2qFV%2Fdistancesensor.png?alt=media\&token=62e7f579-bcf6-4144-a748-1ca93534191c)

The <img src="https://3510336827-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7yGVyBrcpSR8SDSikj%2Fuploads%2FD4WbOZNdGXT2vFPhWevA%2Fdistancesensor_icon.png?alt=media&amp;token=e738c2ad-828e-4b12-aa70-cdac5d4c0e06" alt="" data-size="line"> **V5 Distance Sensor** is a rangefinder which uses a Class 1 Laser reflecting off of an object to determine distance. It connects to the [V5 Brain](/vex-electronics/vex-electronics/vex-v5-brain.md) through a Smart Port on the top of the sensor.

The Distance Sensor can return three types of data: the distance between the sensor and an object, the object's size, and the object's approach velocity. In [PROS](/software/vex-programming-software/pros.md), the Distance Sensor can additionally return a "confidence" reading, which rates how accurate the distance returned from the sensor actually is on a scale from 0 - 63.

The range of the Distance Sensor's readings is between 20mm and 2,000mm. However, under optimal conditions, the Distance Sensor can push past the 2,000mm limit, occasionally reaching distances up to 2,100mm.

In order to measure the distance between an object and the sensor, the Distance Sensor's laser uses a method called "time of flight". An internal clock measures the time at which the laser is sent out, and the time at which the light receptor (also inside the sensor) receives the laser. The equation for time of flight is $$d = t / (2 \* 2.998 \* 10^8)$$ where "d" is the distance reading in meters and "t" is the time it takes for the laser to hit the light receptor in seconds. The accuracy of this sensor is limited, as it has around a 5% accuracy beyond 200 mm, and a +/- 15mm error with distances closer than 200mm meters.

The velocity of an object in relation to the sensor is calculated by taking the delta value of the distance divided by a small period of time.

### Teams Contributed to this Article:

* MTBR (Michigan Task Based Robotics)
* [904U](https://www.youtube.com/channel/UCKvtsL9hJ_x7bqrpl3nJ3Gg) (B.E.S.T.I.E. Robotics)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.purduesigbots.com/vex-electronics/vex-sensors/smart-port-sensors/distance.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
