# Memory trainer

Push the A-button, and every 2
seconds, numbers will be generated. You have to memorise these numbers.
Then wait 30 seconds before you try to list all the numbers in the same order.
Write down the numbers. Now, press the B-button and check if you were right.

You’ll learn how to:
• Work with multiple variables.
• Train your memory. (Which is always a good thing)

Log on before you start the exercise.

### ORIENTATION

Take a look at the example and consider the following questions:

• What should I do?
• What are the goals?
• What are the expectations?
• What can I already do?
• What do I still have to discover?

### PREPARATION

View the steps at 'perform'. Then answer the following questions:

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

### PERFORM

Do the steps one by one. Do you not remember how to do it? View the hints or download the solution.

## STEP 1

### CREATING THE VARIABLES

The purpose of the game is to make our Micro:Bit show several numbers. We’ve decided on 7 numbers, but you could also use more or less than that.
The first step is to create the variables. In this case, we’ll make 7 different variables. That’s because every new number is saved to a variable.
Give these variables a particular name, that will make it easier to work with.

## STEP 2

### A-button

When pressing the A-button, our Micro:Bit has to show the numbers. The numbers have been chosen at random by the Micro:Bit. In order to be able to remember them, we should leave a little break between the numbers.
Do you know what to do, and which blocks to use? We’ll list them for you.
• Put everything into this: “When A-button...”
• Set your variable to a random number between 0 and 9
• show number ...
• pause ...

Now do the same for the other numbers. Don’t forget to make the correct number appear.
When testing the code, you’ll notice that your Micro:Bit shows 7 different numbers. But if it shows two identical numbers in a row, you won’t notice that very well. What your Micro:Bit does, is simply showing the same number for a longer period of time. We can easily resolve this by putting the following blocks under each pause-block.

## STEP 3

### B-button

Of course, you want to check if your friends are right. You can make your Micro:Bit replay the numbers.
Make sure that when you press the B-button, the numbers are replayed. Your Micro:Bit does not have to generate new numbers, it just has to show the variables. Don’t forget to add a little break in between the numbers.

### REFLECTION

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

• Does the program work as I expected? Why / why not?
• What works well?
• What works less well?
• How can I approach it differently?