Repository navigation
Home
Eric Busboom edited this page Sep 26, 2026
·
3 revisions
Start programming an ElecFreaks Nezha robot in MakeCode: closed-loop driving, turns in degrees, and a pose the robot always knows.
Repo: https://github.com/League-Microbit/nezha-robot-template
This repo is a MakeCode project for a two-wheeled ElecFreaks Nezha robot
driven by a micro:bit V2. It is built on the DiffDrive extension, which
measures each wheel with its encoder and corrects it many times a second. That
means move(30, 0) really drives 30 cm straight, move(0, 90) really turns
90°, and the robot can tell you where it is (x, y, heading) at any moment.
| If you want… | Do this |
|---|---|
| A project that already works, with example programs you can copy from | Start from the template: import this repo into MakeCode as a project. |
| To keep your own project and just add the robot driving blocks |
Add the DiffDrive extension: load pxt-diff-drive into any micro:bit project. |
Both ways give you the same diffDrive blocks and JavaScript API.
- A micro:bit V2. The extension does not run on a V1.
- An ElecFreaks Nezha brick with two encoder motors.
- The left wheel on M2 and the right wheel on M1. That is the standard two-motor chassis, and the extension expects it.
- Start from the template: Import this repo into MakeCode as a ready-to-run project, or build it from the command line.
-
Add the DiffDrive extension: Load
pxt-diff-driveinto your own micro:bit project and write your first moves.
- pxt-nezha-diffdrive: the DiffDrive extension's source.
- pxt-diff-drive: the published copy of the extension, which is what MakeCode loads.
-
Releases: ready-to-flash
.hexfiles of this repo's calibration image.
- The repo's
README.mdis out of date. It mentionsmain.ts,main.blocksandtest.ts, which no longer exist; the programs live intest/*.ts. It also links the extension asLeague-Microbit/pxt-diff-drive, whilepxt.jsonpinsLeague-Robotics/pxt-nezha-diffdrive. That's fine, because the first is the published copy of the second, but it's confusing. These wiki pages describe the repo as it is now. - WiFi on the released image uses only credentials saved in the robot's
flash. Save one with
WIFICRED SET, then reset the robot. Flashing erases it. Seedocs/wifi.mdin the repo.