A robot does not see a chair or notice darkness in the broad human sense. Its sensor measures something narrower: distance, reflected light, pressure, motion, temperature, or orientation. Code gives that reading a job in the current task.

Begin with the raw reading

The number 347 is not yet useful. Which sensor produced it? What scale does it use? What values appear near a window, under a desk, or with an object at arm's length? The reading does not arrive labelled ‘dark’ or ‘too close.’

Students should watch the values before programming a response. This exposes variation that a polished final behaviour might conceal.

Make a small table

Move an object to three distances, press and release a button several times, or compare light readings in two parts of a room. Record what stays stable, what changes, and where the ranges overlap.

Now the class has evidence about a limited measuring device. It can ask whether a single sample is reliable, whether the environment matters, and what the sensor cannot detect.

Choose a threshold

A robot might turn when distance is less than 15. The sensor supplies the measurement; the programmer chooses 15. If the robot reacts too late, the threshold or speed may need changing. If readings jump around the boundary, the code may need several samples or a wider margin.

Test cases just above and below the threshold. A wobbling result is worth showing because it reveals whether the limitation belongs to the sensor, sampling, environment, or decision rule.

Expect noise

Distance readings change with angle and material. Buttons can bounce between states. Light sensors respond to the actual room, including the window someone just opened the blind beside. One perfect number every time would be convenient and suspicious.

Repeating measurements, comparing ranges, and calibrating in the working environment are early forms of data literacy.

Close the feedback loop

A patrol robot measures an obstacle, turns, and checks again. The new reading tells it whether the action helped. That cycle—measure, decide, act, measure again—is feedback.

This method prepares students for later discussions of computer vision and AI. More advanced sensing still involves measurements, uncertainty, models or thresholds, and human decisions about success.

A student can narrate the whole loop: the sensor produced this range, the code compared it with that threshold, the motor changed, and the next reading showed whether the turn was enough. If the explanation skips from sensor to intelligent robot, there is probably a decision rule still waiting to be found.

Choose the sensor for the question

Sensor choice also follows the task. A button answers a different question from a light or distance sensor. Adding more sensors does not automatically improve the system; it adds readings, wiring, and cases the program must handle. One well-understood input is a respectable place to begin.

Those choices should remain visible in the final explanation and test record.

Related pages