Skip to content
Eric Busboom edited this page Sep 26, 2026 · 3 revisions

Nezha Robot Template

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.

Get started: pick one

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.

What you need

  • 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.

Pages

Related

  • 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 .hex files of this repo's calibration image.

Notes for maintainers

  • The repo's README.md is out of date. It mentions main.ts, main.blocks and test.ts, which no longer exist; the programs live in test/*.ts. It also links the extension as League-Microbit/pxt-diff-drive, while pxt.json pins League-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. See docs/wifi.md in the repo.

Clone this wiki locally