1
2
3

If This, Then That

Build if-then rules so a robot reacts.

Step 1 of 3

What you'll learn in this level

  • How a sensor reading turns into the right action
  • What an if-then rule is
  • Why the best reaction depends on the situation

Measure, Then Act

Robots don't sense their surroundings with eyes and ears but with sensors. A light sensor measures brightness, a distance sensor measures how far away the nearest obstacle is, a sound sensor measures loudness.

From these readings the robot has to decide what to do. Those decisions live in simple rules following the pattern: if the value is like this, then do that.

How it works

  1. Measure

    The sensor gives you a number. For light, 10 out of 100 means it is almost dark.

  2. Compare

    The robot checks whether the value is above or below a limit.

  3. Apply the rule

    If the value fits, the right if-then rule kicks in.

  4. Act

    The robot carries out the action, then measures again.

In a moment you build the if-then rules for each sensor reading yourself.

Guess first, then experiment

An obstacle shows up 10 cm in front of the robot. Is there exactly one right reaction here?

The robot is in a dark room.

Light sensor: 10% (low)