You are on page 1of 27

Part 2

Basic Movement –
Turning
We Will Learn About…

Part One – Types of Turns


❑ Spin Turn
❑ Sharp 90 Degree Turn
❑ Curved 90 Degree Turn
Part One

Types of Turns
End
Position End
Position

Start Start
Position Position

Spin Turn Sharp 90 Degree Turn Curved 90 Degree Turn

A sharp turn where the robot A sharp turn where the robot A curved turn where the
turns 180 degrees in the turns 90 degrees on the robot turns 90 degrees
same spot same spot
Part Two

Turn 1: Spin Turn


Turn 1: Spin Turn

End
Position

First Input: Second Input:


Steering Direction Distance/Degrees/Time
travelled

This can be done by using the following movement block. The


Start first input control the steering direction
Position
The second input means the motor must travel OR rotate exactly
a full revolution (360 degrees) to cause the robot to spin around.
Your Task…

End
Position
For task 1:

1. Code the robot to move forward for 3 seconds


then do the spin turn on its spot…

2. Next, think about how we can code the sharp


Start
Position 90 Degree Turn.
Solution…

End
Position

Start
Position
Part Three

Turn 2: Sharp 90 Degree


Turn
Turn 2: Sharp 90 Degree Turn

End
Position

First Input: Second Input:


Steering Direction Distance/Degrees/Time
travelled

Start
In this case, we can the robot to turn halfway through Position
compared to the spin turn.

So…100/2 which is a steering direction of 50!


Your Task…

In your groups, code the robot to: End


Position

First move straight for 3 seconds at 50%


speed THEN turn sharply 90 degrees to
the right.
Start
Position
Solution…

End
Position

Start
Position
Part Three

Turn 2: Curved 90 Degree


Turn
Turn 3: Curved 90 Degree Turn

Second Input: Motor


First Input: Spin
Speed Left and Right.
Time

To do a curved 90 Degree Turn, we will need to use a 2 speed


motor block. The speed value entered first is for the left motor
and speed value on the right is for the right motor.

When one motor (hence wheel) spins faster than the other, the
robot will do a curved turn.

For the exact rotations…this is something you and your group


will need to figure out next!
Your Task…

In your groups, code the robot to:

First move straight for 3 seconds at 50% speed


THEN curve 90 degrees to the right.

For the revolutions relating to the curved 90-


degree turn, experiment between the power
applied to the left or right motor. What do you
observe?

1 Revolution = 360 Degrees


Solution…
Your Tasks…
Challenge 1 – Home Run Challenge 2 – Capture the Flag!

Your robot is a baseball player who has to Your robot must capture the flag from the
run to all the bases and go back to home enemy base, spin around in the same spot,
plate. Use the square box provided… come back to base 1 then go to base 3.

Base 2

Base 1 Base 3
Part Four

Introduction to Loops
What are Loops?
Suppose we want our robot to repeat certain actions
again and again…

Would copying the blocks the desired number of


times work? Of course it will!

However, what if we wanted to repeat something


x10
a lot of times? For example, for the case on the
right, I want the robot to move forward and spin
around 10 times! Surely there is an easier way to
do this…
Control

What are Loops?


The Loop Blocks makes repeating the same tasks easy

The added benefit is that a loop can end whenever you


want (a specific number of times, run forever, a
specific condition, etc.

Loop blocks can be found in the Control tab. There are


3 types of loop blocks…
Loop Block 1 Loop Block 2 Loop Block 3

Any blocks placed Any blocks placed Any blocks placed


INSIDE this block will INSIDE this block will INSIDE this block will
be keep repeating for keep repeating keep repeating until a
a certain number of forever. certain condition is
times met to stop it.
Part Five

Loop Block in Action


Your Task…
Let’s go back to the example from the
previous chapter where the robot does a
home run around the box. What was the
pseudocode for this?

Step 1. Move forward


Step 2. Turn a sharp 90 degrees left
Step 3. Move forward
Step 4. Turn a sharp 90 degrees left
Step 5. Move forward
Step 6. Turn a sharp 90 degrees left
Step 7. Move forward
Step 8. Turn a sharp 90 degrees left
Your Task…

a) Looking at the pseudocode below, we can


see that certain steps are being
repeated…Which ones and how many times?

Step 1. Move forward


Step 2. Turn a sharp 90 degrees left
Step 3. Move forward x4
Step 4. Turn a sharp 90 degrees left
Step 5. Move forward
Step 6. Turn a sharp 90 degrees left
Step 7. Move forward
Step 8. Turn a sharp 90 degrees left
Your Task…

b) What block can we use to simplify this code?

4
Flowchart Start
c) Loops can also be represented in a
flowchart to illustrate the control
structure. For the home run challenge, Set mov. speed to
draw the flowchart. 30%

Set mov. to B + C
motors Repeat 4
times

Pseudocode: Move forward for 3


1. Set movement speed to 30% seconds
2. Set movement to both motors B + C
3. Move forward for 3 seconds Turn a sharp 90
4. Turn a sharp 90 degree left degree left
5. Repeat 3-4 4 times.

End
Your Tasks…
Additional Challenge:

This is an open-ended challenge for those groups ahead. Using the materials provided,
create your own circuit or maze or “suburb” where your robot has to navigate through.

You might also like