# One, Two, Three

{% hint style="info" %}

## Teachers Notes

In this lesson the kids will code each button on the micro:bit.&#x20;

The program will word as follows:

* When button A is pressed, the LED's will show 1.
* When B is pressed, the LED's will show 2.
* When A+B is pressed, the LED's will show 3.

The kids will use the **show string** block to display the numbers and the **Input -> on button pressed** block to trigger button presses.

The **on button** **pressed** block can be found under the pink **Input** category. This block allows to to select 3 option from the dropdown namely A, B, A+B which corresponds to each button.

You will use 3 of these blocks. Each for one button
{% endhint %}

## Create your new program

Click on the ***micro:bit*** icon on your toolbar or go to <https://makecode.microbit.org/> on your browser.

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-LskcML6iX1eVw_Fa0KA%2F-LskclQv7ySUOW6M71CY%2FMakeCode1.png?alt=media\&token=1464773f-ef91-4b77-b6ed-527e2515a128)

Click on "***New Project***". The MakeCode editor will appear

Delete the **on start** and **forever** blocks by dragging it to the toolbar

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLB0HMlgU9ta9LJK%2F3-1.png?alt=media\&token=3c155ecb-1af3-4aaf-9adf-8996c7bccc81)

## Show 1 when I press button A

{% hint style="success" %}
Kids task

You will need to program your micro:bit so that when you press button A, the number 1 is displayed
{% endhint %}

Click on the pink **Input** category in the toolbox

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLB3pjvpUE0fWP6t%2F3-2.png?alt=media\&token=c6df3e46-9991-464e-a425-084c3a8fa319)

Drag the **on button press** block and move it to your workspace

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLB5tQjkJNUaKjKw%2F3-3.png?alt=media\&token=33666817-893e-4cd2-889c-e4241b2c7e8f)

Your workspace should look like the image below

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6m7wq-qxNWGplQLmY%2F-Lt6nEMDi9bz4uXs9ubE%2F3-a.png?alt=media\&token=568c864f-26e8-49cf-94ff-1b74ffcd3c9c)

Find the **show string** block under **Basic**

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6m7wq-qxNWGplQLmY%2F-Lt6nEMJaZ9AXF5ZI4sL%2F3-b.png?alt=media\&token=8e10cff7-e855-4f92-8264-3c360f356a9a)

Drag the **show string** block and move it inside the **on button pressed** block&#x20;

Type in **1** in the **show string** block

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLB7jDy7vsg4KQ7x%2F3-5.png?alt=media\&token=999f27fc-d1f4-4a52-a60c-8385e8acce8f)

On the simulator side, press the **A button** and you will see 1 display

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLB84I2t6omtRjfH%2F3-6.png?alt=media\&token=2b4ed718-9a47-4c84-a5f3-23fc928fe1f9)

## Show 2 when I press button B

{% hint style="success" %}
Kids task

You will now need to program your micro:bit so that when you press button B, the number 2 is displayed
{% endhint %}

Drag another **on press button** block to your workspace

Click on the drop down by A and you will see 3 options displayed.&#x20;

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLB9GBao3k8CPMn5%2F3-7.png?alt=media\&token=c67dd360-9eb2-468e-8248-871e1fc2506c)

Select **B** from the dropdown

What this means is that when you press button **B**, something will happen

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBAhPj4F8kyhjyU%2F3-8.png?alt=media\&token=8f451f0d-f285-434f-9e18-96bd07d5c7a3)

Drag a show string block to the **on button button B pressed** code block.

Type **2** in the **show string** code block.

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBBKd_MKVrQ9CXc%2F3-9.png?alt=media\&token=d8926a25-32ee-45a6-86fa-821139377f79)

On the simulator side, press **button B** and the LED should display 2

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBCUaslmLL2qUSE%2F3-10.png?alt=media\&token=df6d2712-0084-4428-b4bf-96e4fe8e935f)

## Show 3 when I press button A+B

{% hint style="success" %}
Kids task

Lastly you will now need to program your micro:bit so that when you press button A and button B, the number 3 is displayed
{% endhint %}

Once again, drag the **on button pressed** code block to your workspace

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBExbpGzJ--6-Nf%2F3-11.png?alt=media\&token=5e524277-e04b-4387-8250-655af30b20f2)

Select the option A+B from the drop down

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBF_MCi9Q-wGBFC%2F3-12.png?alt=media\&token=b6b5b887-14f2-4c5b-ba38-07edae22a1a3)

Drag a **show string** code block to the **on button A+B pressed** code block.&#x20;

Type 3 on in the **show string** code block

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBGa-NQRIn_1uAZ%2F3-13.png?alt=media\&token=464e9558-e578-42c8-b322-068723c43827)

In the simulator, press the **A+B Button** and the LED should display 3

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBH3pfxpgq9BM1m%2F3-14.png?alt=media\&token=4b40ebdc-3efe-4a21-a861-1d2b7c8cbfd6)

## Save, download and run your code

Save you code as **1 2 3** and press save to download.

![](https://1854716099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LskXJjPT2bXMIodrtZq%2F-Lt6l00Zh0PXFGrgByjM%2F-Lt6lLBIZ5pj3ps2bprU%2F3-15.png?alt=media\&token=fc540a4b-dd77-40bf-8d8c-3affe8ef108c)

Drag your code file named microbit-1-2-3.hex to the MICROBIT(D:) folder to upload your code to your micro:bit.

Test your micro:bit by pressing Button A, then Button B then both button A and button B at the same time.

##
