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.

1

Touch Sensor: On or Off

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

Front Left
0
Front Right
0
Left Side
0
Right Side
0

Binary Data

Touch sensors are digital: exactly 0 or 1. Your code checks: if sensor.pressed() — that's all it takes.

Real Uses

Bumper switches on Roombas detect walls. Limit switches stop robot arms at boundaries. Simple but essential.

Fun Fact

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.

2

Ultrasonic: How Far Is That?

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

Distance
150
Unit
cm
Status
Clear

The Cone

Ultrasonic sensors don't see a single point — they detect anything within a cone-shaped area (about 30 degrees wide).

Speed of Sound

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).

Fun Fact

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.

3

Color Sensor: Reading the Rainbow

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.

Red
239
Green
68
Blue
68
Detected
Red

RGB Values

Each channel reads 0-255. Pure red = (255, 0, 0). White = (255, 255, 255). Black = (0, 0, 0). Your code compares these values.

Line Following

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.

4

Gyroscope: Which Way Am I Facing?

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

Angle
0
Unit
degrees
Direction
North

Relative, Not Absolute

A gyro measures how much you've turned, not which way is "north." It starts at 0 when you power on and accumulates rotation.

Precision Turning

Want to turn exactly 90 degrees? Keep turning until gyro.angle() == 90. No guessing. No timing. Just math.

Fun Fact

Your smartphone has a gyroscope too! That's how it knows when you rotate your phone to switch between portrait and landscape mode.

5

GPS: Where Am I Exactly?

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

X Position
0.0
Y Position
0.0
Distance from Origin
0.0

Absolute Position

Unlike the gyro (relative), GPS gives absolute coordinates. The robot always knows WHERE it is, not just which way it turned.

Navigate to Target

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.

6

Camera: Seeing Objects

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.

Objects Detected
0
Nearest Object
None
Nearest Distance
--

Bounding Boxes

Cameras don't "see" like humans. They report rectangles: object type, center position, width, and height. Your code decides what to do.

Object Recognition

Modern camera sensors can classify objects: "ball," "wall," "person." Each detection comes with a confidence percentage.

7

Combining Sensors: Smarter Together

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.

📡 Ultrasonic ON
🎨 Color ON
🔄 Gyro ON
👆 Touch ON
Crashes
0
Line Lost
0
Goal Reached
--
Sensor Decision Log
Toggle sensors on/off, then press "Run Robot" to compare...

Try This

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.

The Real Lesson

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.

Real-World Connection

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.

Sensor Expert!

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.

0
Sensors Explored
0
Readings Taken
0
Time Exploring

Sensors Output Numbers

Every sensor converts physical reality into numbers a program can read.

Different Sensors, Different Data

Touch gives binary, ultrasonic gives distance, color gives RGB, gyro gives angle.

Combining Is Key

A single sensor is limited — combining multiple sensors creates intelligent behavior.

Code Reacts to Data

Robot programs are just if/else decisions based on sensor readings.

Ready to Create?

Put your new knowledge into practice!

More Discoveries

Suggest a Correction