IF the front sensor sees a wall, THEN turn right — a robot converts sensor readings into actions with simple rules. Robot logic is stacking these if-then rules so the machine responds to whatever the world throws at it.
If this, then that
A robot acts on rules: IF the distance sensor sees a wall, THEN stop and turn. Chain a few of these and simple behavior appears. A line-following robot uses one rule for each side: if it drifts off the line, steer back toward it.
Tap the inputs and switch gates — every computer is built from these.
Combine inputs with AND, OR, and NOT — the same logic a robot uses to decide when to act.
- Write a rule for what the robot does when its front sensor sees a wall.
- Write a rule for what it does when the path ahead is clear.
- Add a rule for turning at a dead end.
- Trace your rules through a simple maze and check the robot escapes.
What you should see: You expressed robot behavior as if-then rules and tested them against a maze.