A ready-to-use template for BBC micro:bit V2 robotics projects using Microsoft MakeCode (TypeScript).
- Click "Use this template" → "Create a new repository"
- Open your new repo and click "Code" → "Codespaces" → "Create codespace"
- Wait for setup to complete (first time takes a few minutes)
- Start editing
src/robot.ts— that's where your code goes
- Click "Use this template" → "Create a new repository"
- Clone your new repo
- Run
npm run setup - Start editing
src/robot.ts
| File | Purpose |
|---|---|
src/robot.ts |
Your code goes here. Add functions for your robot. |
src/main.ts |
Demo program — shows what the micro:bit can do. Replace with your own. |
test/test.ts |
Test file — exercises your robot functions. |
pxt.json |
Project config. Add new source files here or they'll be ignored. |
| Command | What it does |
|---|---|
npm run build |
Compile your code to a .hex file |
npm run deploy |
Build and flash to your micro:bit |
npm run test |
Build with test files included |
npm run setup |
Re-run setup (if something breaks) |
To use a motor driver, sensor library, or other MakeCode extension:
- Find the extension's GitHub URL (e.g.,
microsoft/pxt-neopixel) - Add it to
pxt.jsonunder"dependencies":"dependencies": { "core": "*", "neopixel": "microsoft/pxt-neopixel#v0.7.5" }
- Run
npm run setupto install it
Important: MakeCode requires every source file to be listed in pxt.json.
- New
.tsfiles insrc/→ add to"files"array - New
.tsfiles intest/→ add to"testFiles"array - New
.cppfiles → add to"files"array
If you create a file but forget to add it to pxt.json, it will be
silently ignored. No error, no warning.
This project includes an AI coding assistant (Claude Code) that knows how to work with MakeCode and micro:bit. Ask it:
- "How do I add a motor driver extension?"
- "Why am I getting this compiler error?"
- "How do I make my function show up as a block?"
- "Help me write code for the line follower challenge"
MIT