Minds On

Following instructions

  • What would happen if someone used the instructions in this order to brush their teeth?
  • Why is it important to have instructions in the proper order?

Record your responses using a method of your choice.

Action

Coding

A robot can be coded to do many things! Some examples include:

  • measure and mix ingredients for cooking
  • drones can fly in the sky to carry objects or take pictures
  • make music

To do each of these tasks, the robots need to be programmed using coding instructions to complete the tasks.

When people code computers, they are using a language of instructions to have the computer perform a task.

Explore the following SCIENCEXPLOSION video entitled “Secret Code” in which Eric follows step-by-step procedures and learns about coding instructions.

Brainstorm

Coding instructions

  • Why did Erik have to follow the instructions exactly as they were shared with him?
  • What words were used in the instructions?

Record your responses using a method of your choice.

Movements

Eric made certain movements as he followed the instructions to find the clues and the treasure.

Eric moved forward, he moved left, and he moved right a certain number of spaces on his grid to complete the task.

Now it’s your turn! You are going to record instructions for your own robot to make its way through a grid, just like Eric did.

Robot movements

Before you record instructions for your robot, check out the following movements that you can use, their symbols, and what each movement looks like:

Movement

Symbol

What it looks like

Forward

Fwd

The robot moves straight forward from one grid space to the next grid space.

forward

Right Quarter Turn

RT

The robot stays in the same grid space and rotates ninety-degrees to the right.

Right Quarter Turn

Left Quarter Turn

LT

The robot stays in the same grid space and rotates ninety-degrees to the left.

Left Quarter Turn

Use the force!

There are different types of forces that can cause an object to start, stop, or change its direction.

Contact forces happen when two objects come into direct contact with each other.

Non-contact forces happen when forces act on an object without touching it, such as gravity and magnetism.

You can imagine that your robot uses the force of magnetism to travel.

Robot instructions

Explore the following image of a grid. Your robot must be able to move from the starting point to the green square on the grid to reach the scientist signing the paper.

A five-by-five grid with a robot in the bottom right corner labelled “start,” and a scientist in the center space of the top row coloured green and labelled “end.”

Press the following tabs to access and complete three coding instruction tasks.

One way to get the robot to the scientist is to follow instructions that have already been created.

Use the following instructions on the grid to move the robot to the scientist. If you don’t end up at the scientist, go back and try following the instructions again.

Robot Instructions

Fwd

Fwd

Fwd

Fwd

LT

Fwd

Fwd

A five-by-five grid with a robot in the bottom right corner labelled “start,” and a scientist in the center space of the top row coloured green and labelled “end.”

There are three different sets of instructions to get the robot to the scientist, but only two of the instructions will work.

Review the following instructions and test out all three sets on the grid.

Instructions

Set A

Set B

Set C

Fwd

Fwd

Fwd

Fwd

LT

Fwd

Fwd

LT

Fwd

Fwd

Fwd

Fwd

RT

Fwd

Fwd

Fwd

Fwd

LT

Fwd

Fwd

RT

Fwd

Fwd

Fwd

Fwd

A five-by-five grid with a robot in the bottom right corner labelled “start,” and a scientist in the center space of the top row coloured green and labelled “end.”

  • Which two sets of instructions work?

Press ‘Answer’ to access the correct answer.

Instructions A and C get the robot to the scientist.

Now create your own coding instructions that will get the robot to the scientist in a different way. Remember that there are only three movements the robot can make: Forward, Right Quarter Turn, and Left Quarter Turn.

Record your new coding instructions using a method of your choice, then test your instructions on the grid to make sure they are correct.

A five-by-five grid with a robot in the bottom right corner labelled “start,” and a scientist in the center space of the top row coloured green and labelled “end.”

  • Was the robot able to get to the scientist with your new instructions?

If your instructions did not bring the robot to the scientist then review your code, try to find the bug, and test your instructions again.

Obstacles!

The robot now has two obstacles to navigate around: two large chairs that have been placed on the grid. But watch out! The instructions that are supposed to get the robot to the scientist has an error (or bug) in the instructions.

Did you know?

Bugs in code

A bug is an error in coding instructions.

Finding errors in code and fixing them is called debugging.

A student debugging code for a robot on a computer.

Debugging

Use the following instructions on the new grid to find the error, and then debug the instructions.

Robot Instructions With a Bug

LT

Fwd

Fwd

RT

Fwd

Fwd

Fwd

Fwd

A five-by-five grid with a robot in the bottom right corner labelled “start,” and a scientist in the center space of the top row coloured green and labelled “end”. There are also two chairs in the middle row: one in the centre of the grid and the other at the right edge of the grid.

  • What step in the instructions had the error?

Press ‘Answer’ to access the step in the instructions that has a bug.

The error (or bug) was in step 3, which was the second instruction to move forward.

Consolidation

Practicing debugging code

Review the following code and grid, then record a new set of instructions that fixes the bug.

Robot Instructions to Debug

LT

Fwd

Fwd

RT

Fwd

Fwd

Fwd

Fwd

A five-by-five grid with a robot in the bottom right corner labelled “start,” and a scientist in the center space of the top row coloured green and labelled “end”. There are also two chairs in the middle row: one in the centre of the grid and the other at the right edge of the grid.

Record your debugged coding instructions using a method of your choice.

Three excited children playing with a toy robot.

When you are finished recording your code, answer the following questions:

  1. How did you choose your coding instructions? Why did you choose the path you did?
  2. Why might scientists have to code instructions for a robot to move through a space? What are two tasks they could do?
  3. Why is it so important to have the coding instructions exactly right for having a robot perform a specific task?

Reflection

How do you feel about what you have learned in this activity? Which of the next four sentences best matches how you are feeling about your learning? Press the button that is beside this sentence.

I feel…

Now, record your ideas about your feelings using a voice recorder, speech-to-text, or writing tool.