3. Racing

Racing

In these exercises we are going to make our mBot drive in many different ways: automatically, by using your keyboard, ...
 

You will learn

  • To control your mBot with the keyboard.
  • How to programme the mBot to make it drive a fixed track.

Open the mBlock programme on your computer, switch on your mBot an connect it.

PREPARATION

Check the steps in "execute". Answer the following questions:

  • Which steps should I follow?
  • Which steps can I take?
  • How much time do I need?
  • What tools do I need?

EXECUTE

Perform the steps one by one. Have you forgotten how to do it? Look at the hints or download the solution.

STEP 1

Racing by using the keyboard

With a wireless connection, you can control your mBot from a distance. For example, with the arrow buttons of your keyboard.

Can you try this out?

There are several ways to make the programme work. Below, we will give you some hints.

  • If you use the “when...key is pressed” as a header? You will need 4 different programmes.
  • If you use the "flag” as a header? You can use 4 different programmes at a time, but you can also create one big programme.
  • If you use the “mBot programme” as a header? In that case, you can only create one big programme.

Once you start the engine, the mBot keeps driving. To stop the mBot, you will need to create another command.

To stop means to reduce velocity to zero. You can use an extra button on your remote control to stop the mBot.

uitdaging

a)    Can you also make the mBot stop when it gets too close to an obstacle? Use your knowledge from the previous exercise!

b)    You can also make the mBot stop by releasing the key.

STEP 2

Making a circle

Now, we will try to make the mBot drive in a circle.

So, we want the mBot to make a never-ending turn, for this the speeds of the two wheels should be different. Can you try to figure out the result of the following programme? We put the speed left at 50% and right at 100%.

blocks

Now, can you make your mBot drive a bigger or a smaller circle?

STEP 3

Making a square

Now that we have succeeded with the circle, we can try out some other figures. Let's start with a square. At the start of a square, our mBot should move straight ahead. You already know which blocks to use in mBlock.

Next, a bend of 90° must be made. Which block should you use for this?

You can use this block

blocks

Before we make the mBot move straight forward again, we should know how long it takes to turn the mBot 90°.
Try it out yourself, in the following programme, did the mBot rotate by 90° or less or more?

blocks

If you look closely, you will see that a bend of more than 90° has been made. Now you can adjust the duration of the bend, until it reaches 90°.

Now finish the programme!

uitdaging

Now make a figure of your choice. You could make your mBot drive a triangle? If you are up to a real challenge, try to make your mBot drive an eight.

REFLECTING

Look back at the project you just made. Ask yourself the following questions:

  • Does the programme work like I expected?
  • What is working well?
  • What is not working well?
  • How can I do things differently?