Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
## Microsoft MicroCode [https://aka.ms/microcode](https://aka.ms/microcode)
## Microsoft MicroCode

Microsoft MicroCode is an icon-based programming language and editor for young learners to code with the [BBC micro:bit V2](https://microbit.org). MicroCode allows you to program the micro:bit V2 with only an [Arcade shield accessory](#arcade-shields-for-microbit-v2) - _no other computer is required!_ If you prefer the web browser, there's also a MicroCode web app that connects to your micro:bit V2 over WebUSB.

Here's the classic micro:bit _Happy-A-button/Sad-B-button_ program in MicroCode:

![Happy sad program in microcode](./docs/images/generated/sample_smiley_buttons.png)

## Getting started

- **Read the [MicroCode user guide](https://microsoft.github.io/microcode/docs/manual)**
- [try it now!](https://microsoft.github.io/microcode/)

## [Arcade shields](https://microsoft.github.io/microcode/docs/manual#arcade-shield) for micro:bit V2

There are various [Arcade shields](https://microsoft.github.io/microcode/docs/manual#arcade-shield) available on the market today, as shown below.

<img style="width: 40%" src="https://microsoft.github.io/microcode/assets/newbit-shield.png"></img>

## Robot

MicroCode can also be used to [program and control a 2 wheeled rover robot](https://microsoft.github.io/microcode/docs/robot).

![robot line following](https://microsoft.github.io/microcode/docs/images/generated/sample_robot_line_follow.png){:class="sample"}

<img style="width: 40%" src="https://microsoft.github.io/microcode/docs/images/cutebot.jpeg"></img>

## Development

To contribute to MicroCode, please read about [MicroCode development](./docs/develop.md).
> NOTE: MicroCode has moved to [https://github.com/microbit-apps/microcode](https://github.com/microbit-apps/microcode).

## Contributing

Expand Down
23 changes: 6 additions & 17 deletions _includes/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,12 @@
</head>

<body id="root" data-build="{{ site.github.build_revision }}">
<div id="loader" class="lds-rip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NaDXpDl6Y3EKQqAWlBrAB4BIGa5q2GgOU18fcowqzurDbAngCrmLUzVIuAtoAHpGIlFpAdX9p7mTORERkRVIno12N4aiAfPTm+mr6I3/Vn/iH3IurZRbyeLuEh1KSB7YkGD99ijn3pchIHQVKA3Azi1Gz2jx2jZfFTUVoJn8bXXpxZ7WTl69paQ1q94LgagllSQNRKBXkzpRLc2zY4CY69PLfYSQLX2kp0uBiBaQM3JQTq3CIB65rUYpnUNPWDcixFlvBrWUTRW+StrtXvUnNmBn3NM0UtH2RCT+gYcO8oqTfM6A+41Vu84ob303QIhvSoEXwAv2PGabjwX8ump2aIXzqafc8zPmh/2z/c8P9CxQyAFN5H1S/OWNVjT944T2cv50LhqHxe7v+PVXF6WP+4hAAAAAElFTkSuQmCC"
/>
</div>
<div>
<iframe
id="simframe"
title="MicroCode editor"
allowfullscreen="allowfullscreen"
sandbox="allow-popups allow-forms allow-scripts allow-same-origin"
>
</iframe>
</div>
<p>
MicroCode has moved:
<a href="https://microbit-apps.github.io/microcode-classic/docs/manual">
https://microbit-apps.github.io/microcode-classic/docs/manual
</a>
</p>
{% include footer.html %} {% include dialogs.html %}
</body>
</html>
225 changes: 1 addition & 224 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,227 +3,4 @@ title: Developer Docs
image: ./docs/images/generated/sample_smiley_buttons.png
---

MicroCode is open source at https://github.com/microsoft/microcode and welcomes contributions.
The easiest way to get started is to open this repository in a GitHub Codespace and everything will be ready for you.

We recommend using [Visual Studio Code](https://code.visualstudio.com/) as it provides excellent support
for MakeCode editing, Git, and Codespaces.

## Codespaces setup

- open [https://github.com/microsoft/microcode](https://github.com/microsoft/microcode)
- click on `Code` drop down and select `Create Codespace on main`
- you can do your editing from VS Code online or click on `Codespaces` in lower left and select `Open in VS Code` to use the desktop version (must be installed on your machine)
- press "Ctrl + `" to open a terminal and you're ready to go!

In the future, click again on `Code` to find previously created Codespaces.

## Local Install (skip in Codespaces)

- install [Node.js](https://nodejs.org/en/)
- install the MakeCode command line tools (`mkc` for short)

```bash
npm install -g -u makecode
```

- clone this repo

```bash
git clone https://github.com/microsoft/microcode
```

- setup MakeCode project structure (one time only)

```bash
cd microcode
mkc init
```

## Build

Note that you can open terminals directly from VS Code by pressing "Ctrl + `".

- start a compilation server that will automatically compile and reload
a compile web version of the editor

```bash
sh serve.sh
```

- open to web editor at http://127.0.0.1:7001/

To flash a micro:bit,

- build a micro:bit Hex file and deploy

```bash
mkc build --hw n3 -d
```

If you are running in Codespaces, the `-d` option won't work. Instead, right click on `built/binary.hex` in the explorer and select `Download...` to download the hex file to your micro:bit.

## With Jacdac devtools

To load the local editor in a Jacdac devtools page, click on the **sim** link at the bottom
of the local server on http://127.0.0.1:7001/. Or,

https://microsoft.github.io/jacdac-docs/clients/javascript/devtools?jacscript=1&simulators=microbitmicrocode#http://127.0.0.1:7001/index.html?usb=0

## Creating artwork

To preview all artwork, click on the `art` icon at the bottom right of the local editor (and wait...). Use `save` to download all artwork on the `images/generated` folder.

If you want to create/edit new sprites, you should import this web site into https://arcade.makecode.com, using the following directions:

- create 16 x 16 sprite in assets.ts (contains all the artwork for MicroCode)
- copy the code from the JavaScript view of https://arcade.makecode.com
- paste code into assets.ts into VS Code
- make sure it works locally
- git commit and push

You might also be able to commit and push directly from the web site, but we find that this isn't very reliable.

Some art images are precomputed, you will need to load scripts/renderart.ts in MakeCode Arcade and copy the console output back into the project.

## Updating sample

- Browse to http://127.0.0.1:7001/index.html?compress=0
- Once your sample is ready, copy the string after `#` and copy it into `samples.ts`

## Updating GitHub pages

To bump and refresh the github pages javascript and pre-built .hex file, run this script

```bash
sh ./bump.sh
```

A GitHub Action will trigger and update the web site within a few minutes.

## Running Jekyll locally

It is easiest to launch a codespace to get the right setup to run Jekyll (Ruby). Run the Jekyll setup script

```bash
sh scripts/setup-jekyll.sh
```

then launch jekyll

```bash
bundle exec jekyll serve --incremental
```

and nav to http://localhost:4000

## Re-building library

There is library of LED animations etc in `scripts/lib/lib.js`. To rebuild, make sure you have `jacscript` checked out
parallel to `microcode` and run:

```bash
cd scripts
./genlib.sh
```

## Localization

- [ ] `locales/tooltips.json` contains the tooltips displayed on the micro:bit screen
- [ ] `_includes/dialogs.html` contains the webusb dialogs

### Adding tooltips in source code

- add new tooltip to `locales/tooltips.json`
- refresh tooltips.ts

```bash
node scripts/lochex.mjs en
```

### Updating crowdin

- Go to https://crowdin.com/project/makecode/content/files
- click on `Update` for `microcode/tooltips.json` and load `locales/tooltips.json`.

### Refreshing translations

- go to https://crowdin.com/project/makecode/tools/content-delivery
- click `Release` on the microcode distribution
- bump repo

## Dependencies

This app is built with [MakeCode Arcade](https://arcade.makecode.com/), specifically targeting the NRF52833 MCU of the micro:bit V2 (for now). There are a number of repos containing the C++ of the underlying CODAL runtime:

- https://github.com/microsoft/codal-jacdac: an add-on to CODAL that provides Jacdac runtime, virtual machine, and services representing micro:bit features
- https://github.com/microsoft/pxt-arcade: the MakeCode Arcade editor, with support for NFR52833, the MCU of the micro:bit V2, which depends on
- https://github.com/mmoskal/codal-nrf52833-dk: micro:bit device drivers
- https://github.com/lancaster-university/codal-nrf52: CODAL runtime for NRF52 class MCUs
- https://github.com/lancaster-university/codal-core: CODAL runtime

## Build setup for C++ runtime dev

- clone https://github.com/microsoft/pxt-arcade repo at the same level as `microcode`
- run:

```bash
npm install -g pxt-core
cd pxt-arcade
yarn install
mkdir projects
cd projects
mkdir microcode
cd microcode
export PXT_ASMDEBUG=1
export PXT_COMPILE_SWITCHES=size
export PXT_FORCE_LOCAL=yes
export PXT_NODOCKER=yes
export PXT_RUNTIME_DEV=yes
```

- you may use `npm` instead of `yarn`
- you may skip `PXT_NODOCKER` if you don't have locally installed `arm-none-eabi-gcc`
- in `projects/microcode` create `pxt.json` file with the following contents:

```json
{
"additionalFilePath": "../../../microcode",
"dependencies": {
"game---light": "file:../../libs/game---light",
"hw---n3": "file:../../libs/hw---n3",
"device": "file:../../libs/device",
"codal-jacdac-pxt": "file:../../../microcode/codal-jacdac-pxt"
}
}
```

- run `pxt` - it will compile an deploy
- run `code built/codal/libraries/codal-*`
- checkout `main` or `master` in all `codal-*` repos and in `jacdac-c`

Make sure not to delete `projects/microcode/built` since it contains your sources.
If possible, you can move `built/codal/libraries` folder somewhere else, and symlink it inside `built/codal`
to avoid accidentally deleting it.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
MicroCode has moved to [https://microbit-apps.github.io/microcode-classic/docs/develop](https://microbit-apps.github.io/microcode-classic/docs/develop)
31 changes: 1 addition & 30 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,4 @@ title: Frequently Asked Questions
image: ./docs/images/generated/sample_smiley_buttons.png
---

![emoji hello](./images/generated/icon_M19hello.png){:class="icon-sample"}

## How do I share my program?

From the web editor, copy the URL... it contains your whole program.

## How do I print my program?

Click the `screenshot` button at the bottom to get a rendered image of your program that you can share and print.

## How do I translate MicroCode?

Checkout the [localization](./localization) to see how you can help or use a localized build of MicroCode.

## My micro:bit froze and is showing a number

This typically means that MicroCode had a bug and crashed. Here are a few common error codes that are scrolled on the screen:

- **540**: The .hex download was interrupted or failed. Try downloading the .hex file again.
- **020**: Out of memory! Your program is so big that it does not fit in memory anymore... or we have a memory leak somewhere. Try resetting the micro:bit.

Other error codes are [documented in MakeCode](https://makecode.microbit.org/device/error-codes).

## How do I add support for my robot?

If your robot is not [listed](./robots-supported), follow the [instructions](./robots-supported#new-robot) to get it added to the list.

## Can I help?

Yes! MicroCode is open source at https://github.com/microsoft/microcode.
MicroCode has moved here [https://microbit-apps.github.io/microcode-classic/docs/faq](here)
38 changes: 1 addition & 37 deletions docs/jacdac.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,4 @@ title: Jacdac
image: ./docs/images/generated/sample_railroad_crossing.png
---

# Jacdac

![Smiley Button MicroCode program](./images/generated/sample_railroad_crossing.png){:class="screenshot"}

MicroCode will detect [Jacdac](https://aka.ms/jacdac) modules and automatically display tiles for some of them. Tiles are available for all modules in [Kittenbot Jacdac Kit A](https://microsoft.github.io/jacdac-docs/devices/kittenbot/jacdacstarterkitawithjacdaptorformicrobitv2v10/),
as as well as the [Forward Education Climate Kit](https://microsoft.github.io/jacdac-docs/devices/forward-education/climateactionkitv10/). Many of the modules in [Kittenbot Jacdac Kit B](https://microsoft.github.io/jacdac-docs/devices/kittenbot/jacdacdeveloperstoolelectronicmodulekitbv10/) also are supported.

Programming tiles for Jacdac modules appear in the user interface when the modules are connected to the shield. The Jacdac tiles have a small yellow square in the lower-right corner.

### WHEN modules

#### Sensors

- ![magnet sensor](./images/generated/icon_S10.png){:class="icon"} `magnet sensor` detects the presence of a magnet (levels 1 - 5, where 1 means no magnet present and 5 means strong presence of magnetic field)
- ![light sensor](./images/generated/icon_S5.png){:class="icon"} `light sensor` measures the amount of light (levels 1 - 5, where 1 means little light present and 5 means a lot of light present)
- ![moisture sensor](./images/generated/icon_S16.png){:class="icon"}
measures the amount of moisture (levels 1 - 5, where 1 means very dry and 5 means very wet)
- ![distance sensor](./images/generated/icon_S17.png){:class="icon"} `distance sensor` measures the distance to an object (levels 1 - 5, where 1 means very close and 5 means far away)
- ![line sensor](./images/generated/icon_S18.png){:class="icon"} `line sensor` detects
whether the surface under the sensor is dark or light

#### User inputs

- ![slider](./images/generated/icon_S11.png){:class="icon"} `slider` measures the position of a physical slider (1-5, where 1 is minimum position and 5 is maximum position)
- ![dial](./images/generated/icon_S12.png){:class="icon"} `dial` has two associated events: turn left ![turn left](./images/generated/icon_F21L.png){:class="icon"} and turn right ![turn right](./images/generated/icon_F21R.png){:class="icon"}
- ![key](./images/generated/icon_F5.png){:class="icon"} `key` is available in the press/release event.

### DO modules

- ![LED](./images/generated/icon_A8.png){:class="icon"} `LED` set a color animation on a programmable LED strip
- ![relay tile](./images/generated/icon_A22.png){:class="icon"} `relay` controls a relay switch (turning it on or off)
- ![servo power tile](./images/generated/icon_A23.png){:class="icon"} `servo power` controls the power to a servo motor (turning it on or off)
- ![servo set angle tile](./images/generated/icon_A21_.png){:class="icon"} `set servo angle` controls the orientation of a servo motor arm. The ![servo set angle tile](./images/generated/icon_A21_.png){:class="icon"} `servo` arm orientation is mapped to the wall clock hours: `0` (or `12`) is on rotated 90 degree from the resting position to the left, `6` is rotated 90 degree right from the rest position. This operation depends on the servo being powered on.

### Jacdac samples

See the [following programs](./samples.md#jacdac) for examples of how to use Jacdac modules with MicroCode.
MicroCode has moved here [https://microbit-apps.github.io/microcode-classic/docs/jacdac](here)
Loading