Computer Science Grade 7 20 min

Lesson 4: Introduction to Robot Programming: Giving Robots Instructions

Introduce the concept of programming robots to control their behavior.

Tutorial Preview

1

Introduction & Learning Objectives

Learning Objectives Define what a program is in the context of robotics. Write a sequence of commands to make a robot perform a simple task, like moving in a square. Explain why the order and precision of instructions are critical for a robot to function correctly. Differentiate between a single command and a complete program. Use a simple programming interface (block-based or text-based) to send instructions to a virtual or physical robot. Debug a simple robot program by identifying and correcting errors in a sequence of instructions. Ever wished you could tell a robot exactly what to do? 🤖 If you had a personal robot, what's the very first instruction you would give it? In this lesson, you'll learn how to be a robot's boss! We'll explore how to write...
2

Key Concepts & Vocabulary

TermDefinitionExample ProgramA set of step-by-step instructions, written in a language a computer or robot can understand, that tells it exactly what to do.A list of commands like `move_forward()`, `turn_left()`, `move_forward()` that makes a robot navigate a corner is a program. Command (or Instruction)A single, specific action that the robot can perform.`turn_right(90)` is a single command that tells the robot to turn right by 90 degrees. SequenceThe specific order in which commands are listed and executed. For robots, the sequence is extremely important.To move out of a parking spot, the sequence `move_backward(2)` then `turn_left(90)` is very different from `turn_left(90)` then `move_backward(2)`. AlgorithmA plan or a set of rules to be followed to solve a problem. You create an algor...
3

Core Syntax & Patterns

Sequential Execution Commands are executed one after another, from the top of the program to the bottom. The robot will not start the second command in your list until it has completely finished the first one. This is the fundamental way programs flow. Command Syntax: function(parameter) command_name(parameter_value) Most robot commands follow this pattern. You write the name of the action (like `move_forward`) followed by parentheses. Inside the parentheses, you put a parameter that gives a specific value to the command (like how many centimeters to move or degrees to turn). The 'Move and Turn' Pattern Combine `move()` and `turn()` commands to navigate. This is the most basic pattern for getting a robot to move around a flat surface. By combining forward/b...

4 more steps in this tutorial

Sign up free to access the complete tutorial with worked examples and practice.

Sign Up Free to Continue

Sample Practice Questions

Challenging
You want to program a robot to move in a 'U' shape (3 sides of a square). It starts at the top-left, moves down 20 cm, across 20 cm, and then up 20 cm. Which program accomplishes this?
A.move_forward(20) turn_right(90) move_forward(20) turn_right(90) move_forward(20)
B.move_forward(20) turn_left(90) move_forward(20) turn_left(90) move_forward(20)
C.move_forward(20) turn_right(90) move_forward(20) turn_left(90) move_forward(20)
D.move_forward(20) turn_left(90) move_forward(20) turn_right(90) move_forward(20)
Challenging
A robot starts facing North. It runs the following program: `move_forward(10)` `turn_right(90)` `move_forward(10)` `turn_right(90)` `move_forward(10)` What direction is the robot facing at the end of the program?
A.North
B.East
C.West
D.South
Challenging
A student wants to make the robot draw a square that is twice as large as the 30 cm square from the tutorial. They correctly change all `move_forward(30)` commands to `move_forward(60)`. What must they do to the `turn_right(90)` commands?
A.Change them to `turn_right(180)` because the sides are twice as long.
B.Change them to `turn_right(45)` because the angle should be smaller.
C.Nothing. The turn angles for a square are always 90 degrees, regardless of its size.
D.Delete them, as larger squares don't need turns.

Want to practice and check your answers?

Sign up to access all questions with instant feedback, explanations, and progress tracking.

Start Practicing Free

More from Chapter 5: Robotics: Building and Programming Autonomous Machines

Ready to find your learning gaps?

Take a free diagnostic test and get a personalized learning plan in minutes.