LEGO Power Functions Clone Remote Control (Mould King M-0006 / Kaiyu / Bandra / AKOGD / MayD / etc)

LEGO] Power Functions (eg LEGO set 8293) is a now-retired LEGO motor and light system.

However, the connectors and motor design appear to have been picked up and used by a variety of other manufacturers to add motor functionality to lego-ish kits. They're known by various names, but the exact model that has been tested is the Mould King M-0006.

The Mould King M-0006 is a 4 output, LiPo rechargeable control box that can be controlled by a remote control but also by bluetooth from a phone app. The remote control is only on/off but the box itself can output differing speeds.

It will control official LEGO motors, but also clone Power Functions motors as well.

The remote control works by listening for Bluetooth LE Advertising packets which are crafted in a particularly strange way. We've reverse engineered the code into a library here which you can use.

How to use

You just use the mouldking (About Modules) module on any Bluetooth LE capable Espruino device. First you must call .start() - this advertises what appears to be a 'pairing' packet.

After a second or so the remote control will notice your device, and you can then call .set({}). In the argument, you can specify the 4 outputs a/b/c/d each of which can have a value from -7 (full reverse) to 0 (off) to 7 (full forward).

Leaving a value out will set it to 0.

var lego = require("mouldking");
// You must leave one second after 'start' to allow the remote to be paired

setTimeout(function() {
  lego.set({a:1 }); // motor a = slow
  setTimeout(function() {
    lego.set({c:7}); // motor c = fast
    setTimeout(function() {
      lego.set(); // all off
    }, 1000);
  }, 1000);
}, 1000);


exports.get_nrf_payload = function (addressData, commandData) { ... }

/* Starts advertising with the default 'hello' message. This is needed
to pair with a just turned on remote control
exports.start = function () { ... }

/* Set the state of the outputs on the device. o is an object with {a,b,c,d}
each of which can contain a number from -7 to 7.
exports.set = function (o) { ... }


These appear to be available from a variety of places, but be careful as there seem to be a variety of different options.


While right now this library handles the control box, a combined motor+control box is available which is included in kits such as KAIYU 561PCS 4WD City Remote Control Rotating Drift Racing Car.

It would appear that this uses the same control code but with different magic numbers in commandData and a different BLE UUID. It may be possible to use this same module to make those work, once the correct numbers are found.

For instance you can scan for Mould King packets from the app with UUID 65280 / 0xFF00:

NRF.setScan(d => print(new Uint8Array(d.manufacturerData).join(",")), {filters : [{ manufacturerData:{65280:{}} }] });

But for Kaiyu you need to use UUID 49664 / 0xC200:

NRF.setScan(d => print(new Uint8Array(d.manufacturerData).join(",")), {filters : [{ manufacturerData:{0xC200:{}} }] });

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.