← Course home← Back: Python return valuesNext: Two-wheel steering →M17 · Robotics
Robotics · M17

Motor, Meet Sensor

Rover rolls down a straight lane toward a wall. Choose one motor power and a sensor threshold that leave the cart in the safe stopping band.

Simulation only: this bounded model does not control hardware. Your choices and predictions clear when you leave. If you turn saving on, only which puzzles you finished and how much help you used is kept on this device. Test accounts also share it, and lesson timing, with the site’s maintainer.

Step through a separate lane with actual sensor readings.
◇ Your mastery goalM17 · Motor and distance sensor

Complete all 3 required tasks with a correct prediction, an inspected trace and an explanation that shows the concept. At least 2 must be independent checks, without answer-level help.

✓ Qualifying tasks: 0 / 3◎ Independent checks: 0 / 2 required
Practice · Gentle approach

Set up the controller

0/3 checks · 0/2 independent transfers

Use power 1 to approach a wall and stop 3–8 cm away. Pick a threshold that also works on changed distances.

Read the lane

Start0 cm from lane originWall30 cm from lane originStarting sensor30 cmTarget band3–8 cm before wall

The distance sensor reads wall − position before every one-second movement tick.

Build the controller

Choose the motor power and distance where Rover should command zero power. Power 1 is requested for this task; powers 1, 2 and 3 travel 2, 4 and 6 cm per tick.

At each sensor check, the controller either stops when the reading is at most your threshold or moves forward one whole tick.

Predict before running

Predict the final position and wall distance, movement ticks, and sensor checks. A normal stop includes one last check with no movement after it.

Help for this laneHints build up. Worked help and solutions are deliberate choices.

Highest help used here: none

For Further Reading and Exploration

These are outside sites with their own rules. You will see a notice before you leave. Pick one, not all.

  • Open Roberta Lab

    Use blocks to drive a virtual robot's motors in a simulator. See what changes with a different speed or time. Logging in is only for saving.

    • Hands-on
    • Has accounts
  • Tinkercad Circuits

    Build a virtual circuit with a motor and run code to spin it. No parts to buy. Making an account needs a parent or guardian.

    • Hands-on
    • Has accounts
    • May count visits
  • Webots robot simulator

    A free robot simulator that supports Python controllers. It needs a big install on a capable computer, so an adult should help.

    • Hands-on
    • May need an install
    • Ask an adult
    • May count visits
  • Raspberry Pi Foundation Projects

    Step-by-step projects. Some use sensors or motors and need hardware, so read the parts list before you start.

    • Hands-on
    • May count visits

Some extra resources are hidden. A parent or guardian can show them in Help.