5. Playing soccer

Playing soccer

The new soccer season has begun. This time, you’re part of the mBot pro league.

Go do some warm up drills and prepare for the match of your life.

You get 30 minutes to programme your mBot.

You'll learn how to:

  • Programme the remote buttons.

You'll be needing



Before you can begin, you should plot the course. Make sure you have a well-defined playing field and 2 goals.

Needless to say, you’ll also need a ball.

Challenge a friend. Who can score the most often?

Do you not have anything to keep the score? During the first year, using the micro:Bit, you made a scoreboard.

To do

  • Put the ball in the middle of the playing field.
  • Turn both mBots with their backs to the ball and start the first programme by pushing the built-in button on the mBot. (explanation: see the next step)
  • You have to programme the remote yourself. (that means you can't use the default programme)
  • You get 30 minutes to write and finalise your programme.


The built-in buttons

At the start of the match, the backs of both mBots are turned to the ball. To make the match fair, we first let the mBots make a move.

Only afterwards, you can steer the mBot.

Add this code to your mBot.


This ensures that:

  • Your leds turn red.
  • Your mBot drives forwards.
  • Your mBot spins for a while.
  • Your leds turn green.

After this start, you can steer the mBot.



You have to steer the mBot by using the remote. You already did this during de eerste les.  You can just copy your code.

If want to, you can still adapt the code you wrote back then.

We don’t think it’s always convenient that our mBot keeps driving even when you release the button. You can think of something.

To do this, use these blocks.


Paste this code under the code you already had. 



You can add as many assignments as you want. We’ll name a few, but please do use your own imagination.

  • add extra players.
  • use a goalkeeper.
  • organise a school competition.
  • ...

Don’t hesitate to let us know some of your ideas.
Have fun!!!