Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views20 pages

MakeCode For Micro Bit

This document provides a comprehensive guide to programming the Micro:bit using MakeCode, covering various lessons that include displaying messages, using sensors, managing variables, and controlling outputs. It introduces concepts like micro-controllers, sensors, and the LAB:bit extension board, along with practical projects for hands-on learning. Each chapter includes objectives, project instructions, and challenges to enhance understanding of programming and electronics.

Uploaded by

Zubair Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views20 pages

MakeCode For Micro Bit

This document provides a comprehensive guide to programming the Micro:bit using MakeCode, covering various lessons that include displaying messages, using sensors, managing variables, and controlling outputs. It introduces concepts like micro-controllers, sensors, and the LAB:bit extension board, along with practical projects for hands-on learning. Each chapter includes objectives, project instructions, and challenges to enhance understanding of programming and electronics.

Uploaded by

Zubair Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MakeCode for Micro:bit

Create - Learn - Code


1
Chapter 3: Micro:bit | Lesson 1

Objective Reviewing the skills learned in Grade 4

Displaying messages

Last year, you discovered how to program a Micro:bit.


Let us review some of its features.

Launch MakeCode and try the missions.

Describe the mission 1:

Describe the mission 2:

List your favourites

List 3 names of your friends: List 3 of your favourite foods:

How to run the program MakeCode?


MakeCode is available in 2 versions: Online and Offline.
If you have Internet connection, launch the If you don’t have Internet connection, install
1 2 the Offline version by visiting the following
Online version from the following address:
https:// makecode.Micro:bit.org/ address:
https://www.microsoft.com/en-us/makecode

Project

Launch MakeCode and create the program to list the


names of your friends if the button A is pressed and
list the foods you prefer if the button B is pressed.

36
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
More missions to perform

Launch Makecode and build the mission shown on the


right.

Describe the result:

Micro-controllers around us

A micro-controller is an electronic board designed to


perform specific tasks.

It is made by engineers and contains a program to


control its functioning.

Finding micro-controllers around us

A micro-controller is found in every electronic device


we use every day.

In a fridge, a micro-controller is used to:

freepik.com

In a lift, a micro-controller is used to:

Time to practise
Now it is your turn to know more about micro-controllers. Open Power Point
to create the presentation below:
1. Give examples of objects controlled by a micro-controller.
2. Create 5 Slides containing a picture and a brief description. 37
2
Chapter 3: Micro:bit | Lesson 2

Objective Displaying shapes on the screen of the Micro:bit

Displaying pictures and messages

On the Micro:bit board, 25 leds form a screen to


display any kind of information (shapes, messages, etc).

The Micro:bit’s screen is OFF.

The Micro:bit’s screen is ON.

What is displayed on the Micro:bit screen?

From the Basic category, you can choose the


blocks needed to show information on the
Micro:bit’s screen.

The blocks of the basic category


While exploring the Basic category, you identify many
blocks that manipulate the Micro:bit’s screen.

Try each block and then describe its use.

Sustainability VIBES
Let us talk!
What can you see in the picture below?
www.freepik.com

Why is it not good to heat the earth?

38
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Challenge

Launch MakeCode and try the projects below.

39
3
Chapter 3: Micro:bit | Lesson 3

Objective Introducing the Shake sensor

Sensing your steps

Answer the following questions:

Do you do sports? Yes No

How many times per week?

Is sport good for health? Yes No

Counting the sensors

Does the human being have sensors in his body?


Yes No

If yes, list them.

Name sensors you know in a car

Name sensors you know in a fridge

40
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Defining a sensor

A sensor is a device that can detect and measure things


in the world around us. It acts like our body’s senses,
such as our eyes, ears, nose, and skin. Sensors are
made to collect information and send it to a computer
or another device such as the Micro:bit, so we can
understand what’s happening in our environment.

The temperature sensor

The thermometer is a sensor that


measures temperature. When you 36
38

39
40

41
42

43
44

List the sensors you see in the picture above.


put it in your mouth, it can tell you
34

37

35

if you have fever or not.


Examples of sensors

There are many different types of sensors for


different purposes. Some sensors can measure light,
sound or even the speed.

Shaking the Micro:bit

From the category,


move the shake block.

Insert the block

Examine the Micro:bit, press the Shake


button to shake it.

Project

Create the project on the Micro:bit to display your


name when you shake it and to play music when you
press button A.

41
4
Chapter 3: Micro:bit | Lesson 4

Objectives Managing variables to count steps

Defining a variable

A variable is used to store information that our


program needs to remember. Just like in real life,

6 7
variables have names in which we can place different
values. We can then use these values later in our code.

The variable is compared to a box.


5
3 4
7
2
Each variable has a name.

And it can contain information. steps


1
The variable is named

And it contains

Let us move to practice

It is now the time to create the project to count the


steps you are making during a sport activity.

Attach the Micro:bit to your shoes in order to count


your steps.

Do we need a variable in this project?


Yes No

If yes, why?

42
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Steps to do the project

Click on

Click on

Name the variable.

Examine the new blocks created.

Place the block “set step” into


the block “on start”.

Create the script “on shake” as


shown on the right.

Each time you click on shake, the


step will add one.

Project

Create the project on the Micro:bit to add one step if


you press the button A and to reduce one step if you
press the button B. Look at the hint on the right.
43
5
Chapter 3: Micro:bit | Lesson 5

Objective Controlling the Micro:bit with the push buttons

Defining a push button

A push button is everywhere around us. We use it in


our daily life without paying attention.

A push button can have two statuses only:

On or Off.

Pressed or Not Pressed.

What do you do to turn on the light?

What do you do to turn on the TV?

Push buttons are everywhere

A push button is an input device to control any action.


On the Micro:bit, two buttons are installed:

Button A.

Button B.

With the two buttons A and B, you can control any


action you want to take with the Micro:bit.

Project

Create the following project:

1- Create a variable named “count”.


2- When you run the Script, the value of “count” will take the value 0.
3- If you press button A, the value of “count” will add 1.
4- If you press button B, the value of “count” will be deducted by 1.

44
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Step by step

Click on

Click on

Name the variable “count”.

Insert the block “set count to 0”


in the block “on start”.

Click on

Move the block

Build the script as shown.

Create the script to program the button B.

Project

Create the Script to display odd numbers when you


press button A.

45
6
Chapter 3: Micro:bit | Lesson 6

Objective Measuring the temperature with the Micro:bit

Reading the temperature

The Micro:bit is equipped with a temperature sensor.


When the Micro:bit reads the temperature, you can
program it to take the action you want.

You can display a message.

You can reproduce a sound.

Describe what you can do with the Micro:bit


You can activate a motor.

Taking actions with Micro:bit

In this project, the temperature will be shown on


the Micro:bit’s screen and a message is displayed
accordingly.

Display “Too hot” if the temperature is greater Display “Cool weather” if the temperature
than 30 degrees. is less then 30 degrees.

1 Click on

2 Examine the block Enjoy building the project

3 Click on

4 Examine the block

5 Examine the block

46
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Drawing with the turtle

It is possible to draw shapes on the screen of the


Micro:bit.
All you need is to add the “Turtle” blocks.

1 Click on

2 Add
3

3 Examine the blocks of the “microturtle” category.

Describe the utility of the blocks below:

2 5

3 6

4 7

Challenge

Build the two scripts shown on the right and examine


the behaviour of the turtle.

1 2

47
Objectives
S k iof
llsthe lesson 7 : 1- Introducing the LAB:bit board 2- Adding the
extension of the LAB:bit to the program MakeCode
7
Chapter 3: Micro:bit | Lesson 7

What is the LAB:bit?

LAB:bit is an extension board where you can connect your Micro:bit in order to program
additional input and output devices in an easy way.

Insert the Micro:bit into the edge


1
connector.

With MakeCode, you program


2 the Micro:bit.

The lab:bit is available to be ordered online:


https://macrotronics.net/
Adding the extension lab:bit
In order to add the blocks of the lab:bit, we have to add its extension.

Once you create a project in


1
MakeCode, click on the category
Advanced.

In the search bar, type “lab” and press


2
enter. Then choose the Kitronik-lab-
bit

48
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
The lab:bit category
The lab:bit category including its sub categories is now
added to the main categories:

Inputs: represent all the inputs


1
found on the lab:bit

Traffic light: contains the


2 commands to manipulate the
traffic lights on the lab:bit

Dice: contains the commands to


3 manipulate the Dice lights on the
lab:bit

Colour lights: contains the


4 commands to manipulate the Describe what you see in the above picture

Colour lights on the lab:bit


Motor: contains the commands
5 to manipulate the motor on the
lab:bit

Discovering my LAB:bit
Examine the LAB:bit board and identify its different components.

49
Objective
S kof
i l lthe
s lesson 8 : Using the Ultrasonic sensor of the LAB:bit to
measure a distance
8
Chapter 3: Micro:bit | Lesson 8

Extending your experience

In this lesson, we will use the LAB:bit to measure a distance. From the lab:bit, we will be using
the Ultrasonic sensor.

1 Examine the Ultrasonic Sensor.


3

The LAB:bit kit is controlled by a


2 Microbit.
1

3 Insert the Micr:obit in its socket.

Measuring a distance
In order to make the LAB:bit measure a distance using the Ultrasonic sensor, follow the steps below:

1 From the LAB:bit category, click on


1

Examine the blocks to measure the


2
distance.

In the “forever” block, build the script


3
shown. 2

The distance measured by the LAB:bit


4
is shown on the Microbit’s screen.

4
3

50
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Creating a warning message
Now it is time to add a condition to the Script in order to
make a warning sound when the distance measured is
less than 10cm.

1 Click on

2 Move

3
Add the comparison
3 block as shown.

4
4 Set the correct condition.

What happens if the distance


5
measured is greater than 10cm?

What happens if the distance


6 measured is less than 10cm?

More projects to explore on the LAB:bit


Visit www.zero1.education to explore more ideas on projects on the LAB:bit. 51
Objectives
S k iof
llsthe lesson 9 : 1- Controlling the rotation of the wheel of the
LAB:bit 2- Converting the distance read by the Ultrasonic sensor to a speed
9
Chapter 3: Micro:bit | Lesson 9

Turning the wheel

The wheel should be attached to a motor in order to make it turn.


On the LAB:bit, a motor is installed in order to experiment its behaviour with other components.

1 Examine the Wheel. 1

2 Examine the Motor.

3 The motor has two characteristics.


2
a The speed.

b The rotation (clockwise and counter-clickwise).

Turning the wheel


In order to make the wheel turn, follow the steps below:

1 Click on
3

2 Click on

Examine the blocks of the Motor


3 category.

4
The two properties of the motor are in
4 included in the same block .

Challenge
Build the Script to control the motor of the LAB:bit as follow:
1- If button A is pressed, the motor turns clockwise.
2- If button B is pressed, the motor turns counter-clockwise.
3- If buttons A+B are pressed, the motor stops

52
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous
Controlling the speed of the motor with the Ultrasonic sensor
In this project, you will learn how to control the speed of the
motor according to the distance detected by the Ultrasonic
sensor.

The speed of the motor will be defined by the distance detected


by the Ultrasonic sensor.

1 Click on
3
2 Click on

Move the block “turn motor” inside the


3 “forever” block.

4 Click on
5

Move the block “measure distance in


5 cm” inside the “turn motor” block.

Connect the LAB:bit on your computer


6 to download the Script.

7 What happens if the distance


measured is equal to 30cm?

What happens if the distance


8 measured is equal to 10cm?

More projects to explore on the LAB:bit


Visit www.zero1.education to explore more ideas on projects on the LAB:bit. 53
Objective of the lesson 10 : Controlling the display of random numbers
using the button A
10
Chapter 3: Micro:bit | Lesson 10

Objective Using the block <if> to control the Micro:bit

Time to play with the dice

Do you want to create a dice with your Micro:bit?


Follow the steps below:

In the block forever, insert the


block show number.

From the category Math, insert the


block pick number and set the lower
and higher values of the dice.

When you run the Script, you will


notice that random numbers are
displayed continuously on the screen
of the Micro:bit.

To stop showing the random numbers


automatically, move the block if from
the category Control.

From the category Input, insert the


block button A is pressed.

Now you can use the Micro:bit board


to play with the dice. Each time you
press the button A, a random number
between 0 and 10, will be shown.

More ideas... more projects

To discover more projects


on Micro:bit, visit the link
www.zero1.education

54
Follow us on Twitter, Facebook and Instagram for more updates and news: /LinfoPourTous

You might also like