English

Introduction to BBC Micro:Bits

This activity has been designed for use within our Introduction to Micro:Bits workshop.

For any other learners we have a Micro:Bit Online Workshop Series.

Click on the next button below to get started.

Makecode

You will need to have Makecode open in a different tab or window so you can switch back and forth as needed between the exercises and your program.

If you haven't already, open Makecode. This link will open it in a new tab.

On Makecode you can then select the blue square labelled 'New Project'.

It should then ask for a project name - we advise you use your first name(s) to help identify files later.

Click on create and it should open the programming screen and simulator.

If you get stuck at anytime - please ask a member of staff to help you.

Bronze Challenge 1

Have a picture inside the 'on start' block.

Inside the Basics menu there are two blocks you can choose from:

Creating your own image using the 'show leds' block and clicking on the individual squares to select which are lit.

Selecting a pre-made image using the 'show icon' block. The down triangle allows you to select from a range of different images.


Bronze Challenge 2

Add an animation to the 'forever' block.

An animation is two or more pictures that when repeated in the forever loop creates the idea of a moving image.

Here are a couple of examples you can try out:

Tip: Although we show two different options above - you should only have one 'forever' loop inside a program.

Bronze Challenge 3

Have a different picture appear when you press button A.

There are two ways to do this:

The Quick Way

This block stands on its own - it does not go inside the 'on start' block or 'forever' loop.

This method works for adding a single instruction for when a button is pressed. However, if you add more than one the program may behave funny as both the button program and the forever loop will try to run at the same time.

The Clever Way

This block will need to be added to your program inside the 'forever' loop.

This method is a little bit more fiddly but worth it later. This allows any program you write for the button to finish before returning to the rest of the program inside the 'forever' loop

You can then choose to use either the 'show icon' or 'show leds' block inside your chosen method.

Bronze Challenge 4

Add a sound effect (not music) to your 'on start' program

In the Music menu you will need to scroll down until you reach the micro:bit (V2) section to find this block:

There are different sound effects available by clicking on the arrow for 'giggle'.

You will then need to decide where in your on-start program you want to add it.

Please keep do not change the 'until done' option.

Bronze Challenge 5

Have the word 'Shhh!' appear on the screen if there is a loud sound.

There is a clue in the challenge that we'd like you to do this using an if statement inside the forever block.

The if statement should look something like this:

A 'string' is a programming term for a combination of letters, numbers, and/or symbols.

Silver Challenge 1

Clear the screen and add a welcome message to the end of your 'on start' program.

Using the 'Basic' clear screen block stops images/icons from moving with the text.

Here is an example of how your on-start program may look:

Silver Challenge 2

Have different pictures appear for pressing button B and when both buttons are pressed.

You can do this the same way as you already have for Button A.

However, the best way to do this would be in the forever loop with this:

Notice how the statement is ordered. Pressing both buttons at the same time needs to go first.

You can then put the chosen icons or design your own show led blocks to go inside each option.

Silver Challenge 3

Add sound effects to the different buttons.

Remember that the sound effects are in the Music menu under micro:bit(V2).

Silver Challenge 4

Create a different message or picture for when the Micro:Bit detects it is quiet.

If you made an if statement for when it detects a loud noise we can add an else if section for a quiet noise.

It would look something like this:

Add your message or image to the else if section.

Gold Challenge 1

Using a 'repeat' block, can you replace your picture in the 'on-start' program with an animation?

The repeat block can be found inside the Loops menu.

It will run the program inside it as many times as you've told it. However 4 times is a good number for testing without taking too long.

Remember you can create an animation with two or more images.

Here's an example:

Gold Challenge 2

Choose a way for the Micro:Bit to react when tilted left and another for being tilted right.

Again, there are two approaches to this:

The Quick Way

These are blocks that stay outside of the on start and forever blocks but can cause unwanted behaviours.

The Clever Way

Using an if statement inside the forever block

Gold Challenge 3

At the end of your 'forever' program, have the Micro:Bit show you the value of the sound level detected.

The sound level value is a number (between 0 and 255) so will need the show number block.

You will probably want to also include a clear screen block before showing this number.

The new blocks to add to the end of your forever program look something like this:

Extension

Congratulations for completing all the exercises!

But wait! There's so much more you can do with this program...

You now have all the parts for starting to create your own virtual pet.

Change the images and actions (such as having button A feeding the pet, button B to play with the pet) in your program.

If you're feeling confident - try adding some variables for hunger and happiness levels.