|
2 | 2 | title: MicroCode Guide |
3 | 3 | description: The MicroCode UI and languages |
4 | 4 | --- |
| 5 | + |
| 6 | +<CardGrid> |
| 7 | + <Card title="MicroCode home page"> |
| 8 | +  |
| 9 | + </Card> |
| 10 | + <Card title="Emotion badge program"> |
| 11 | +  |
| 12 | + </Card> |
| 13 | +</CardGrid> |
| 14 | + |
| 15 | +## The emotion badge program |
| 16 | + |
| 17 | +The MicroCode home page (above, left) has three selectable tiles |
| 18 | +for editing the current program, selecting from a sample of programs |
| 19 | +(including the empty program), and recovering a program previously |
| 20 | +saved in one of three slots. |
| 21 | + |
| 22 | +Selecting the edit tile with the A button on the display-shield |
| 23 | +the very first time will open the sample `emotion badge` program |
| 24 | +in the MicroCode editor (above, right). |
| 25 | + |
| 26 | +As both the display shield and micro:bits have A and B buttons, |
| 27 | +we will use `d-A` and `d-B` to refer to the shield's buttons |
| 28 | +and `m-A` and `m-B` to refer to the micro:bit's buttons. Note |
| 29 | +that the micro:bit buttons have triangular labels next to them. |
| 30 | + |
| 31 | +### Reading the program |
| 32 | + |
| 33 | +The program consists of four **When-Do** rules: |
| 34 | + |
| 35 | +- the **When** section is the left side of the rule and describes an event. |
| 36 | +- the **Do** section is the right side of the rule and describes an action to perform. |
| 37 | + |
| 38 | +The first two rules fire on the press of the m-A button. |
| 39 | +The second two rules fire on the press of the m-B button. |
| 40 | +The first and third rules display animations of happy and sad faces. |
| 41 | +The second and fourth rules play happy and sad sounds. |
| 42 | + |
| 43 | +### Running the program |
| 44 | + |
| 45 | +You can run the program in one of three ways: |
| 46 | + |
| 47 | +- use the direction pad to navigate to the green play tile and press `d-A` |
| 48 | +- press either the `m-A` or `m-B` button on the micro:bit |
| 49 | +- press the `menu` button on the display shield |
| 50 | + |
| 51 | +The micro:bit will indicate the program is running by a quick circular |
| 52 | +animation on the LED display. |
| 53 | + |
| 54 | +### Stopping the program |
| 55 | + |
| 56 | +The program will continue to run until |
| 57 | + |
| 58 | +- you move to and select the stop tile (to the right of the play tile), or |
| 59 | +- you edit the program |
| 60 | + |
| 61 | +### Running without the display shield |
| 62 | + |
| 63 | +If you remove the micro:bit from the shield and power it via battery or |
| 64 | +USB, the last program you edited in MicroCode will begin to run. |
| 65 | + |
| 66 | +## Creating your first program |
| 67 | + |
| 68 | + |
| 69 | +import { Card, CardGrid, LinkCard } from '@astrojs/starlight/components'; |
0 commit comments