Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 10+ · Coding · How computers work
Sensors and robots
Sense: read a sensorDecide: check theruleAct: move or light alampand around again
A robot senses, decides with a rule, then acts.
The big ideaA robot senses, decides, then acts. Sensors are its eyes, ears and touch.

How it works

Bo only followed steps, so he bumped into the table. Steps say what to do, and sensors show what is there.

A sensor measures the world: light, sound, touch or distance.

A robot does three things over and over: it senses, it decides with a rule, and it acts.

A robot follows its rule using what its sensors tell it, and nothing more.

1if the table is close:2 turn3else:4 go forward
Bo's rule for the table.
The sensor• light• sound• touch• distance• heatIt measures• how bright it is• how loud it is• a bump or a press• how far away it is• how warm it is
Sensors and what they measure.
Daylight• sunny• cloudy• dusk• dark• nightBo's lamp• off• off• on• on• on
Bo's night-light as the day gets darker.

Example 1: Bo and the table

  1. Bo's distance sensor sends out a tiny ping of sound, and it finds the table is close.
  2. Bo checks his rule: if the table is close, turn.
  3. His wheels turn him away, with no bump.

Example 2: The distance ping

  1. The ping bounces back from the table.
  2. The longer it takes to come back, the farther away the table is.
  3. A quick ping back means the table is close.

Example 3: The night-light

  1. Bo's rule says: if the room is dark, turn on the lamp.
  2. In bright sun and under a cloudy sky there is plenty of light, so the lamp stays off.
  3. At dusk the sensor reads low light, so the lamp comes on, and it stays on in the dark and at night.

Example 4: The cloud at noon

  1. A big cloud drifts over at noon, and the room dims.
  2. Bo's sensor says dim, and his rule says lamp.
  3. The lamp comes on, and Bo was not silly: he followed his rule.

Words to know

sensor
Measures the world, like light, sound, touch or distance.
rule
What a robot decides by.
sense
Read the world with a sensor.
decide
Check a rule.
act
Move a wheel or light a lamp.

Watch out

Try it

  1. Which sensor measures how bright it is?
  2. A robot reads a distance sensor. Is that sensing, deciding or acting?
  3. Turning a wheel is sensing, deciding or acting?
  4. Bo's ping takes longer to come back. Is the table nearer or farther?
  5. True or false: a robot knows things its sensors cannot tell it.
Answers: 1. A light sensor · 2. Sensing · 3. Acting · 4. Farther · 5. False
Try at homeLook for sensors with a grown-up: an automatic light, a door that opens by itself, a thermostat, a phone that turns its screen. For each, say what it senses, what the rule might be, and what it does. Sense, decide, act.
For grown-upsLook for sensors at home together: an automatic light, a door that opens by itself, a thermostat, a phone that turns its screen. For each, ask what it senses, what the rule might be, and what it does.
Open these notes on screenScan the code, or go to tutorpip.com.