Skip to content
RoboLearn
Not completed

Infrared distance sensors

SensorsIntermediate20 minUse side distance sensors ↓Before this: Ultrasonic distance sensors

What you’ll learn

  • Three kinds of IR distance sensor and when to use each
  • Strengths and weaknesses compared with ultrasonic

IR obstacle modules (digital)

An IR LED and receiver side by side. If enough IR reflects back, the output switches. A screw sets the trigger distance (usually a few cm up to about 30 cm). Cheap and fast, but only says “something is near”, not how far.

Sharp IR sensors (analog)

Sensors like the GP2Y0A21 measure distance by triangulation: the angle at which reflected light lands on a detector. They give an analog voltage for roughly 10–80 cm. The output is not linear and reads wrongly when closer than the minimum range, so use the datasheet’s curve or a lookup table.

Time-of-flight (ToF) laser sensors

Sensors like the VL53L0X time how long a laser pulse takes to return, much like ultrasonic but with light. They talk over I²C, give millimetres directly, have a narrow beam and work to about 1–2 m depending on the model.

IR versus ultrasonic

Ultrasonic IR / ToF
Beam Wide cone Narrow
Soft materials Poor Fine
Black or shiny surfaces Fine Can be poor
Bright sunlight Fine Can be affected
Speed ~20 readings/s Faster

Many robots use both: ultrasonic forwards for a wide view, IR or ToF on the sides for wall following.

Finished this lesson?