Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.
/ powered-up Public archive

A Node.js SDK for programming the LEGO® Powered Up platform.

License

Notifications You must be signed in to change notification settings

clebert/powered-up

Repository files navigation

PoweredUpJS

Build Status Package Version

A Node.js SDK for programming the LEGO® Powered Up platform.

Disclaimer: LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this software.

Getting started

Please install the @powered-up/api package as described here.

The following example uses a Smart Move Hub (included in the LEGO® Boost Set 17101) and activates the built-in motor A while the button is held down:

// @ts-check

const {SmartMoveRobot} = require('@powered-up/api');
const {autorun} = require('mobx');

const moveRobot = new SmartMoveRobot();

autorun(() => {
  const {buttonPressed, encodedMotorA, rgbLight} = moveRobot;

  if (!encodedMotorA || !rgbLight) {
    return;
  }

  if (buttonPressed) {
    rgbLight.setColor({red: 0, green: 255, blue: 0});

    encodedMotorA.runWithPower(100);
  } else {
    rgbLight.setColor({red: 255, green: 0, blue: 0});

    encodedMotorA.brake();
  }
});

You can find some more examples in the demo package.

Implementation status

Smart Move Hub 2 I/O (Robot) Smart Hub 2 I/O (Robot)
Button ✅ Supported ✅ Supported
VoltageSensor ✅ Supported ✅ Supported
CurrentSensor ✅ Supported ✅ Supported
RGBLight ✅ Supported ✅ Supported
InternalEncodedMotor ✅ Supported ❌ N/A
InternalTiltSensor ⚠️ Not yet implemented ❌ N/A
Motor ✅ Supported ✅ Supported
EncodedMotor ✅ Supported ⚠️ Not yet implemented
VisionSensor ⚠️ Not yet implemented ⚠️ Not yet implemented

Packages

A reactive library for controlling LEGO® Powered Up devices.

Internal packages

A reactive library for managing BLE connections to LEGO® Powered Up hubs.

A partial implementation of the LEGO® Powered Up BLE protocol in JavaScript.

Related links


Copyright (c) 2018-present, Clemens Akens. Released under the terms of the MIT License.

About

A Node.js SDK for programming the LEGO® Powered Up platform.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published