5. Your remote control

Your remote control

After reading this page, you will be able to fully personalise the mBot remote control! 
We will start off with a few basic functions. After that, you are free to do as you please! 

You will learn:

  • How you can use the different buttons on the remote control in a programme. 
  • How you can install a programme on mBot which uses the remote control. 

Open the mBlock programme on your computer, turn on your mBot and connect. 

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

For this exercise, you will need to connect the mBot to a computer via the USB cable.  You will be working with the “when mBot(mcore) starts up” block and will be sending the programme to your mBot.

blocks

blocks

In order to programme the buttons of the remote control, we will use the following block: 

blocks

For instance, you will be able to combine this block with an “if...then” block. 

Let’s get started! 

STEP 2

Controlling the mBot

Let’s start by controlling our mBot.  By pressing the up on the remote control, the mBot will drive forward.  You can choose the speed at which the mBot will drive.

Is your programme not functioning? 

Because we want the mBot to keep driving when the up button is pressed, you will need to use the “repeat forever” block. 

Naturally, the mBot also needs to be able to stop.  This can be achieved by pressing another button.  The mBot can also be stopped by releasing the up button.  Do you know how to do this? 

STEP 3

All directions

Will you try to programme the down, left and right buttons as well?

STEP 4

Selecting the speed

Let’s take it a step further.  Now, we also want to be able to select the speed using the numbers on the remote control. We will start off by setting up two speeds, for example 50 and 100.  The mBot must be driving at these speeds whenever we press the arrow buttons.  To do this, we will need another variable. 

Do you know how to do this?  Then get programming. Afterwards, test it out to make sure your programme is working.

uitdaging

a)    Make sure that each number on the remote control is allocated to a different speed. 

b)    Programme an additional button which will turn the car’s lights on or off.  Whenever you are driving, the lights need to be shining even brighter. 

STEP 5

Now it's up to you

Now that you know how to programme the remote control, you can combine this with all the other knowledge from the previous exercises.  Below are a few suggested ideas, but you are free to do your own thing!  Or you can try out all of the ideas mentioned below...

  • Turn your mBot into a music instrument, which you can play by using the remote control. 
  • Ensure that you can choose the colours of the LED lights by using the remote control.  You are free to choose the settings of the buttons.  You can also choose to control the right or left light separately. 
  • Turn your mBot into a Jukebox.  To do this, make a few (short) songs.  When you press the numbers, one of these songs will be played. 
  • Try programming the remote control yourself, as it is set by default. 

goed gedaan!

How nice that you could create your own remote control!  Will you let the other children in your coding class see what your remote control can do? 

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?

Download

Click on the links below to download the solutions: