A Robot Without Senses Is a Blind Machine
In What Is a Robot? we said a robot works in a loop: sense, think, act. The sensor is where everything starts: without it the robot does not know there is a wall ahead, that it is tilting, or that something touched it. The good news is that in 2026 robot sensors are cheaper and easier to use than ever: a few dollars buy an accurate distance sensor, and less than ten buys a complete motion-tracking unit.
This guide covers the main sensor families you will meet in your first projects, how each one works, when to use it, and what is new enough in recent years to be worth knowing.
Ultrasonic: The HC-SR04
The most famous beginner sensor of all. The idea is simple: it sends out a high-frequency sound pulse we cannot hear, measures the time the wave takes to hit an object and bounce back, and calculates the distance from the speed of sound. Its practical range is about 2 cm to 4 meters, it runs on 5 volts, and it has two pins: Trigger to start a measurement and Echo to receive the result.
When do you use it? Detecting obstacles in front of a moving robot, measuring liquid level in a tank, or any medium-range distance that does not need high precision. We built a complete project with it here: Arduino obstacle-avoiding robot with the HC-SR04.
An important 2026 note: many modern boards (like the ESP32) use 3.3-volt logic, while the HC-SR04's Echo pin outputs 5 volts. The fix is simple: two resistors forming a voltage divider between the sensor and the board protect the pin.
Infrared: Fast and Short-Range
IR sensors work on a similar idea but with invisible light instead of sound. The best-known classic example is Sharp's family, such as the GP2Y0A21, which measures roughly 10 to 80 cm and outputs an analog voltage proportional to the distance, so you read it directly with an ADC pin.
Infrared has a second, very common use: the line sensor, such as the TCRT5000, which tells a white surface from a black one at very close range. It is the heart of the line-following robots that most school competitions start with.
Laser Time-of-Flight (ToF): The Newcomer Worth Knowing
The biggest recent shift in distance sensing is the spread of tiny Time-of-Flight chips like ST's VL53L1X. It is a very small chip that fires invisible laser pulses, times their return precisely, reaches about 4 meters, and talks to the board over I2C with just two wires.
Compared with the HC-SR04: far smaller, faster, unaffected by soft surfaces that absorb sound, and now priced within hobby reach. If your project is compact or needs fast repeated measurements, this is the modern choice.
IMU: How a Robot Knows It Is Tilting
An IMU packs an accelerometer (which senses gravity direction and vibration) and a gyroscope (which senses rotation speed) into one chip. The most popular hobbyist model for years has been the MPU-6050 (six axes); it is still available and cheap, but newer generations like TDK's ICM-20948 add a magnetometer (nine axes) and perform better.
When do you need an IMU? A two-wheeled balancing robot, a drone holding its attitude in the air, or any robot that must know its orientation while moving. Readings come over I2C as well, and ready-made Arduino libraries handle most of the math.
Touch: The Simplest and Most Overlooked Sensor
A mechanical switch (a limit switch or bump switch) is a sensor too: it gives a clean digital "something touched me" signal. Mount it on the front of a robot as a bumper, or at the end of an arm's travel so it knows when to stop. Do not dismiss it for being simple; plenty of industrial robots rely on it as a last line of protection.
Cameras and Computer Vision
A camera is the richest sensor of all: a single image carries more information than everything above combined. The trade-off is that it needs a stronger processor than an Arduino; this is where a Raspberry Pi 5, or an ESP32-S3 with its small camera, comes in. The free OpenCV library is the de facto standard here, and its latest 2026 releases (the 4.x series) let you detect colors, shapes, and faces in a few lines of Python. And when AI starts interpreting the image, you are in the world of AI in robots.
Lidar: The Big Robots' Eye
Lidar is "radar with lasers": a spinning unit that sends beams in every direction and builds a complete map of the surroundings dozens of times per second. The photo at the top of this article shows a mobile robot carrying a yellow SICK lidar unit. It is the brains behind robot vacuum cleaners and self-driving cars. Prices have dropped a lot and small hobby units exist, but it remains a later step, after you have mastered the sensors above.
Wiring and Reading: Only Three Ways
Every sensor we mentioned connects in one of three ways:
- Simple digital: the touch switch and line sensor; a digital pin reads 0 or 1.
- Analog: like the Sharp IR; you read it with an ADC pin as a value that scales with the measurement.
- I2C bus: like the VL53L1X and IMUs; just two wires for data and clock, and several sensors can share the same bus.
Before wiring anything, check the voltage match: is the sensor 5 volts or 3.3, and can your board take it? One minute reading the sensor's page is cheaper than a burnt board.
Where to Start?
Start with the HC-SR04: it is the cheapest and the most educational. Add an IMU once your project moves or tilts, and try the VL53L1X when you hit the limits of ultrasound. Every new sensor you master unlocks a project that was impossible before.
Wheel Encoders: Knowing How Far You Drove
In the motors article we said a DC motor has no idea where it is. The fix is the encoder: a slotted or magnetic disc on the motor shaft with a sensor that counts pulses as it spins. From the pulse count you know how many turns the wheel made, and from its circumference you get the real distance the robot drove, even its live speed. Some DC gearmotors come with an encoder built into the back; they are an excellent pick for your second robot, when you want it to drive an exact distance or turn exactly 90 degrees.
You will also meet other sensors later: temperature and humidity sensors like the DHT11 and DHT22, gas sensors like the MQ-135, and load cells for weighing. And if you need distance sensing in a wet or outdoor spot, there is a waterproof ultrasonic variant called the JSN-SR04T. All of them work through the same three methods we just covered: digital, analog, or a bus, so never fear a new one.