How Robots See: The World Through Sensors
Robots can't see like you do. They read numbers. Let's find out what those numbers mean.
Robots can't see like you do. They read numbers. Let's find out what those numbers mean.
The simplest sensor gives the simplest data: 0 (not pressed) or 1 (pressed). That's it. No gradients, no maybe. Click the bumpers to trigger them.
Click or tap the bumper panels on the robot to press them
Touch sensors are digital: exactly 0 or 1. Your code checks: if sensor.pressed() — that's all it takes.
Bumper switches on Roombas detect walls. Limit switches stop robot arms at boundaries. Simple but essential.
The first industrial robots in the 1960s used ONLY touch sensors. They'd press against a surface and know "I've arrived." Everything else came later.
An ultrasonic sensor sends out a sound pulse and measures how long the echo takes to return. Drag the wall closer or farther to see the distance reading change.
Drag the wall left and right to change the distance
Ultrasonic sensors don't see a single point — they detect anything within a cone-shaped area (about 30 degrees wide).
Sound travels at 343 m/s. The sensor times the echo: distance = speed x time / 2 (divide by 2 because the sound travels there AND back).
Bats use the exact same principle! They emit ultrasonic clicks and listen for echoes. Scientists call it echolocation — robots just call it an ultrasonic sensor.
A color sensor shines a light on a surface and measures the reflected Red, Green, and Blue components. Click the colored surfaces below to see what the sensor reads.
Each channel reads 0-255. Pure red = (255, 0, 0). White = (255, 255, 255). Black = (0, 0, 0). Your code compares these values.
The most common use: detecting a black line on white floor. The sensor sees high values on white, low values on the line. Simple but powerful.
A gyroscope measures rotation. It tells your robot exactly how many degrees it has turned from its starting position. Drag the dial to rotate the virtual platform.
Click and drag to rotate the platform
A gyro measures how much you've turned, not which way is "north." It starts at 0 when you power on and accumulates rotation.
Want to turn exactly 90 degrees? Keep turning until gyro.angle() == 90. No guessing. No timing. Just math.
Your smartphone has a gyroscope too! That's how it knows when you rotate your phone to switch between portrait and landscape mode.
A GPS sensor reports the robot's exact X/Y position on the field. Drag the robot around the grid and watch the coordinates update in real-time.
Click and drag the robot to move it around the grid
Unlike the gyro (relative), GPS gives absolute coordinates. The robot always knows WHERE it is, not just which way it turned.
With GPS, you can calculate: "I'm at (2, 3) and need to reach (5, 7)." The robot can compute the angle and distance to any point.
A camera sensor detects objects and reports their position, size, and type. Click objects in the scene to see how the camera identifies them with bounding boxes.
Click objects to toggle detection. Drag objects to reposition them.
Cameras don't "see" like humans. They report rectangles: object type, center position, width, and height. Your code decides what to do.
Modern camera sensors can classify objects: "ball," "wall," "person." Each detection comes with a confidence percentage.
A single sensor is limited. Toggle sensors on and off below to see how the robot's behavior degrades. With all sensors active, it follows the line, avoids walls, and reaches the goal. Disable one and watch it struggle.
Run with all sensors ON, then reset and disable Ultrasonic. The robot crashes into walls it can't see. Disable Color instead — it loses the line. Each sensor prevents a different failure.
No single sensor is enough. Ultrasonic can't see the line. Color can't see walls. Gyro can't see anything — it just remembers which way you turned. Together, they cover each other's blind spots.
Self-driving cars use 30+ sensors for exactly this reason. If the camera is blinded by sun, LIDAR still works. If rain confuses LIDAR, radar still works. Redundancy saves lives.
You've explored how robots perceive the world through raw sensor data. Every autonomous robot — from Roombas to Mars rovers — relies on these same principles to navigate and make decisions.
Every sensor converts physical reality into numbers a program can read.
Touch gives binary, ultrasonic gives distance, color gives RGB, gyro gives angle.
A single sensor is limited — combining multiple sensors creates intelligent behavior.
Robot programs are just if/else decisions based on sensor readings.
Put your new knowledge into practice!