# IR sensors

In robot sumo, there are two common types of sensors used for object detection: ultrasonic and infrared (IR) sensors. Ultrasonic sensors use sound waves to measure distance while IR sensors rely on presence of infrared radiation. In this guide, we mainly recommend IR sensors because they respond quicker due to using light instead of sound waves. Granted, ultrasonic sensors are better at accurately measuring distances, but in robot sumo this is not required.&#x20;

IR sensors come in two types: analog and digital sensors. Analog sensors, such as the Sharp [GP2Y0A21YK0F](https://www.pololu.com/product/136) sensor outputs a voltage that corresponds to a distance. Digital sensors such as the JSUMO's  [JS40F](https://www.jsumo.com/js40f-digital-infrared-ir-distance-sensor-min-40-cm-range) uses a 0 or 1 to determine if an object is present.

<figure><img src="/files/z7KpOKhv9HKmHSaZtq7t" alt=""><figcaption><p>JSUMO JS40F IR sensors</p></figcaption></figure>

{% hint style="warning" %}
If using JSUMO sensors, be mindful of limited documentation that is provided.&#x20;
{% endhint %}

<figure><img src="/files/B5wEdjWgo6uAqhxF5Ql1" alt="" width="375"><figcaption><p>SHARP GP2Y0A21YK0F</p></figcaption></figure>

{% hint style="info" %}
There is an Arduino library called [SharpIR](https://www.arduino.cc/reference/en/libraries/sharpir/) that makes reading analog signals from several models of IR sensors a lot easier.&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sumo.cometrobotics.org/electronics/choosing-parts-for-your-robot/ir-sensors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
