LEGO Powered UP is the successor to Power Functions, the system for adding electronics to LEGO models. Powered UP is a collection of ranges - starting with LEGO WeDo 2.0 released in 2016, LEGO Boost released in 2017, and LEGO Powered UP released in 2018. It also includes the 2018 Duplo App-Controlled Train sets.
Powered UP has a few improvements over Power Functions:
-
The use of Bluetooth Low Energy makes it easy to control from a computer, and even write code for.
-
The ability to use sensors to react to events happening in the real world opens up a whole new world of possibilities.
-
As Powered UP hubs and remotes pair with each other, the system allows for a near unlimited number of independently controlled models in the same room. Power Functions was limited to 8 due to the use of infra-red for communication.
Node.js v8.0 required.
npm install node-poweredup --save
node-poweredup uses the Noble BLE library by Sandeep Mistry. On macOS everything should function out of the box. On Linux and Windows there are certain dependencies which may need installed first.
Note: node-poweredup has been tested on macOS 10.13 and Debian/Raspbian on the Raspberry Pi 3 Model B.
While most Powered UP components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.
Name | Type | WeDo 2.0 Smart Hub | Boost Move Hub | Powered UP Hub | Availability |
---|---|---|---|---|---|
WeDo 2.0 Tilt Sensor | Sensor | Yes | Yes | Yes | 45300 |
WeDo 2.0 Motion Sensor | Sensor | Yes | Yes | Yes | 45300 |
WeDo 2.0 Medium Motor | Motor | Yes | Yes | Yes | 45300 76112 |
Boost Color and Distance Sensor | Sensor | Partial | Yes | Yes | 17101 |
Boost Tacho Motor | Motor/Sensor | Partial | Yes | Partial | 17101 |
Powered UP Train Motor | Motor | Yes | Yes | Yes | 60197 60198 |
Powered UP LED Lights | Light | Yes | Yes | Yes | 88005 |
-
The Boost Color and Distance sensor only works in color mode with the WeDo 2.0 Smart Hub.
-
When used with the WeDo 2.0 Smart Hub, the Boost Tacho Motor does not support rotating the motor by angle.
-
When used with the Powered UP Hub, the Boost Tacho Motor does not support rotating the motor by angle. It also does not support rotation detection.
-
Plugging two Boost Tacho Motors into the Powered UP Hub will crash the Hub (This requires a firmware update from LEGO to fix).
const PoweredUP = require("node-poweredup");
const poweredUP = new PoweredUP.PoweredUP();
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
await hub.connect(); // Connect to the Hub
await hub.sleep(3000); // Sleep for 3 seconds before starting
while (true) { // Repeat indefinitely
hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
await hub.sleep(1000); // Do nothing for 1 second
await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
await hub.sleep(1000); // Do nothing for 1 second
}
});
poweredUP.scan(); // Start scanning for Hubs
More examples are available in the "examples" directory.
Thanks go to Jorge Pereira (@JorgePe), Sebastian Raff (@hobbyquaker), Valentin Heun (@vheun), Johan Korten (@jakorten), and Andrey Pokhilko (@undera) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered UP protocols.
- PoweredUP ⇐
EventEmitter
- WeDo2SmartHub ⇐
Hub
- BoostMoveHub ⇐
LPF2Hub
- PUPHub ⇐
LPF2Hub
- PUPRemote ⇐
LPF2Hub
- DuploTrainBase ⇐
LPF2Hub
Kind: global class
Extends: EventEmitter
- PoweredUP ⇐
EventEmitter
- .scan()
- .stop()
- .getConnectedHubByUUID(uuid) ⇒
Hub
|null
- .getConnectedHubs() ⇒
Array.<Hub>
- "discover" (hub)
Begin scanning for Powered UP Hub devices.
Kind: instance method of PoweredUP
Stop scanning for Powered UP Hub devices.
Kind: instance method of PoweredUP
Retrieve a Powered UP Hub by UUID.
Kind: instance method of PoweredUP
Param | Type |
---|---|
uuid | string |
Retrieve a list of Powered UP Hubs.
Kind: instance method of PoweredUP
Emits when a Powered UP Hub device is found.
Kind: event emitted by PoweredUP
Param | Type |
---|---|
hub | WeDo2SmartHub | BoostMoveHub | PUPHub | PUPRemote | DuploTrainBase |
Kind: global class
Extends: Hub
- WeDo2SmartHub ⇐
Hub
- new WeDo2SmartHub()
- .name
- .uuid
- .rssi
- .batteryLevel
- .setName(name) ⇒
Promise
- .setLEDColor(color) ⇒
Promise
- .setLEDRGB(red, green, blue) ⇒
Promise
- .setMotorSpeed(port, speed, [time]) ⇒
Promise
- .rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒
Promise
- .playTone(frequency, time) ⇒
Promise
- .setLightBrightness(port, brightness, [time]) ⇒
Promise
- .connect() ⇒
Promise
- .disconnect() ⇒
Promise
- .subscribe(port, [mode]) ⇒
Promise
- .unsubscribe(port) ⇒
Promise
- .sleep(delay) ⇒
Promise
- .wait(commands) ⇒
Promise
- "button" (button, state)
- "distance" (port, distance)
- "color" (port, color)
- "tilt" (port, x, y)
- "rotate" (port, rotation)
- "attach" (port, type)
- "detach" (port)
The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
Kind: instance property of WeDo2SmartHub
Read only: true
Properties
Name | Type | Description |
---|---|---|
name | string |
Name of the hub |
Kind: instance property of WeDo2SmartHub
Read only: true
Properties
Name | Type | Description |
---|---|---|
uuid | string |
UUID of the hub |
Kind: instance property of WeDo2SmartHub
Read only: true
Properties
Name | Type | Description |
---|---|---|
rssi | number |
Signal strength of the hub |
Kind: instance property of WeDo2SmartHub
Read only: true
Properties
Name | Type | Description |
---|---|---|
batteryLevel | number |
Battery level of the hub (Percentage between 0-100) |
Set the name of the Hub.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
name | string |
New name of the hub (14 characters or less, ASCII only). |
Set the color of the LED on the Hub via a color value.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
color | number |
A number representing one of the LED color consts. |
Set the color of the LED on the Hub via RGB values.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
red | number |
green | number |
blue | number |
Set the motor speed on a given port.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
Param | Type | Description |
---|---|---|
port | string |
|
speed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
[time] | number |
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
Ramp the motor speed on a given port.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful completion of command.
Param | Type | Description |
---|---|---|
port | string |
|
fromSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
toSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
time | number |
How long the ramp should last (in milliseconds). |
Play a tone on the Hub's in-built buzzer
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful completion of command (ie. once the tone has finished playing).
Param | Type | Description |
---|---|---|
frequency | number |
|
time | number |
How long the tone should play for (in milliseconds). |
Set the light brightness on a given port.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
Param | Type | Description |
---|---|---|
port | string |
|
brightness | number |
Brightness value between 0-100 (0 is off) |
[time] | number |
How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
Connect to the Hub.
Kind: instance method of WeDo2SmartHub
Overrides: connect
Returns: Promise
- Resolved upon successful connect.
Disconnect the Hub.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful disconnect.
Subscribe to sensor notifications on a given port.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
port | string |
|
[mode] | number |
The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
Unsubscribe to sensor notifications on a given port.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
port | string |
Sleep a given amount of time.
This is a helper method to make it easier to add delays into a chain of commands.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved after the delay is finished.
Param | Type | Description |
---|---|---|
delay | number |
How long to sleep (in milliseconds). |
Wait until a given list of concurrently running commands are complete.
This is a helper method to make it easier to wait for concurrent commands to complete.
Kind: instance method of WeDo2SmartHub
Returns: Promise
- Resolved after the commands are finished.
Param | Type | Description |
---|---|---|
commands | Array.<Promise.<any>> |
Array of executing commands. |
Emits when a button is pressed.
Kind: event emitted by WeDo2SmartHub
Param | Type | Description |
---|---|---|
button | string |
|
state | number |
A number representing one of the button state consts. |
Emits when a distance sensor is activated.
Kind: event emitted by WeDo2SmartHub
Param | Type | Description |
---|---|---|
port | string |
|
distance | number |
Distance, in millimeters. |
Emits when a color sensor is activated.
Kind: event emitted by WeDo2SmartHub
Param | Type | Description |
---|---|---|
port | string |
|
color | number |
A number representing one of the LED color consts. |
Emits when a tilt sensor is activated.
Kind: event emitted by WeDo2SmartHub
Param | Type |
---|---|
port | string |
x | number |
y | number |
Emits when a rotation sensor is activated.
Kind: event emitted by WeDo2SmartHub
Param | Type |
---|---|
port | string |
rotation | number |
Emits when a motor or sensor is attached to the Hub.
Kind: event emitted by WeDo2SmartHub
Param | Type | Description |
---|---|---|
port | string |
|
type | number |
A number representing one of the peripheral consts. |
Emits when an attached motor or sensor is detached from the Hub.
Kind: event emitted by WeDo2SmartHub
Param | Type |
---|---|
port | string |
Kind: global class
Extends: LPF2Hub
, Hub
- BoostMoveHub ⇐
LPF2Hub
- new BoostMoveHub()
- .current
- .name
- .uuid
- .rssi
- .batteryLevel
- .setMotorSpeed(port, speed, [time]) ⇒
Promise
- .rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒
Promise
- .setMotorAngle(port, angle, [speed]) ⇒
Promise
- .setLightBrightness(port, brightness, [time]) ⇒
Promise
- .setName(name) ⇒
Promise
- .setLEDColor(color) ⇒
Promise
- .setLEDRGB(red, green, blue) ⇒
Promise
- .connect() ⇒
Promise
- .disconnect() ⇒
Promise
- .subscribe(port, [mode]) ⇒
Promise
- .unsubscribe(port) ⇒
Promise
- .sleep(delay) ⇒
Promise
- .wait(commands) ⇒
Promise
- "button" (button, state)
- "distance" (port, distance)
- "color" (port, color)
- "tilt" (port, x, y)
- "rotate" (port, rotation)
- "attach" (port, type)
- "detach" (port)
The BoostMoveHub is emitted if the discovered device is a Boost Move Hub.
Kind: instance property of BoostMoveHub
Read only: true
Properties
Name | Type | Description |
---|---|---|
current | number |
Current usage of the hub (Amps) |
Kind: instance property of BoostMoveHub
Overrides: name
Read only: true
Properties
Name | Type | Description |
---|---|---|
name | string |
Name of the hub |
Kind: instance property of BoostMoveHub
Overrides: uuid
Read only: true
Properties
Name | Type | Description |
---|---|---|
uuid | string |
UUID of the hub |
Kind: instance property of BoostMoveHub
Overrides: rssi
Read only: true
Properties
Name | Type | Description |
---|---|---|
rssi | number |
Signal strength of the hub |
Kind: instance property of BoostMoveHub
Overrides: batteryLevel
Read only: true
Properties
Name | Type | Description |
---|---|---|
batteryLevel | number |
Battery level of the hub (Percentage between 0-100) |
Set the motor speed on a given port.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
Param | Type | Description |
---|---|---|
port | string |
|
speed | number | Array.<number> |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
[time] | number |
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
Ramp the motor speed on a given port.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful completion of command.
Param | Type | Description |
---|---|---|
port | string |
|
fromSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
toSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
time | number |
How long the ramp should last (in milliseconds). |
Rotate a motor by a given angle.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful completion of command (ie. once the motor is finished).
Param | Type | Default | Description |
---|---|---|---|
port | string |
||
angle | number |
How much the motor should be rotated (in degrees). | |
[speed] | number | Array.<number> |
100 |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
Set the light brightness on a given port.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
Param | Type | Description |
---|---|---|
port | string |
|
brightness | number |
Brightness value between 0-100 (0 is off) |
[time] | number |
How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
Set the name of the Hub.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
name | string |
New name of the hub (14 characters or less, ASCII only). |
Set the color of the LED on the Hub via a color value.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
color | number |
A number representing one of the LED color consts. |
Set the color of the LED on the Hub via RGB values.
Kind: instance method of BoostMoveHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
red | number |
green | number |
blue | number |
Connect to the Hub.
Kind: instance method of BoostMoveHub
Overrides: connect
Returns: Promise
- Resolved upon successful connect.
Disconnect the Hub.
Kind: instance method of BoostMoveHub
Overrides: disconnect
Returns: Promise
- Resolved upon successful disconnect.
Subscribe to sensor notifications on a given port.
Kind: instance method of BoostMoveHub
Overrides: subscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
port | string |
|
[mode] | number |
The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
Unsubscribe to sensor notifications on a given port.
Kind: instance method of BoostMoveHub
Overrides: unsubscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
port | string |
Sleep a given amount of time.
This is a helper method to make it easier to add delays into a chain of commands.
Kind: instance method of BoostMoveHub
Overrides: sleep
Returns: Promise
- Resolved after the delay is finished.
Param | Type | Description |
---|---|---|
delay | number |
How long to sleep (in milliseconds). |
Wait until a given list of concurrently running commands are complete.
This is a helper method to make it easier to wait for concurrent commands to complete.
Kind: instance method of BoostMoveHub
Overrides: wait
Returns: Promise
- Resolved after the commands are finished.
Param | Type | Description |
---|---|---|
commands | Array.<Promise.<any>> |
Array of executing commands. |
Emits when a button is pressed.
Kind: event emitted by BoostMoveHub
Param | Type | Description |
---|---|---|
button | string |
|
state | number |
A number representing one of the button state consts. |
Emits when a distance sensor is activated.
Kind: event emitted by BoostMoveHub
Param | Type | Description |
---|---|---|
port | string |
|
distance | number |
Distance, in millimeters. |
Emits when a color sensor is activated.
Kind: event emitted by BoostMoveHub
Param | Type | Description |
---|---|---|
port | string |
|
color | number |
A number representing one of the LED color consts. |
Emits when a tilt sensor is activated.
Kind: event emitted by BoostMoveHub
Param | Type | Description |
---|---|---|
port | string |
If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used. |
x | number |
|
y | number |
Emits when a rotation sensor is activated.
Kind: event emitted by BoostMoveHub
Param | Type |
---|---|
port | string |
rotation | number |
Emits when a motor or sensor is attached to the Hub.
Kind: event emitted by BoostMoveHub
Overrides: attach
Param | Type | Description |
---|---|---|
port | string |
|
type | number |
A number representing one of the peripheral consts. |
Emits when an attached motor or sensor is detached from the Hub.
Kind: event emitted by BoostMoveHub
Overrides: detach
Param | Type |
---|---|
port | string |
Kind: global class
Extends: LPF2Hub
, Hub
- PUPHub ⇐
LPF2Hub
- new PUPHub()
- .current
- .name
- .uuid
- .rssi
- .batteryLevel
- .setMotorSpeed(port, speed, [time]) ⇒
Promise
- .rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒
Promise
- .setLightBrightness(port, brightness, [time]) ⇒
Promise
- .setName(name) ⇒
Promise
- .setLEDColor(color) ⇒
Promise
- .setLEDRGB(red, green, blue) ⇒
Promise
- .connect() ⇒
Promise
- .disconnect() ⇒
Promise
- .subscribe(port, [mode]) ⇒
Promise
- .unsubscribe(port) ⇒
Promise
- .sleep(delay) ⇒
Promise
- .wait(commands) ⇒
Promise
- "button" (button, state)
- "distance" (port, distance)
- "color" (port, color)
- "tilt" (port, x, y)
- "attach" (port, type)
- "detach" (port)
The PUPHub is emitted if the discovered device is a Powered UP Hub.
Kind: instance property of PUPHub
Read only: true
Properties
Name | Type | Description |
---|---|---|
current | number |
Current usage of the hub (Amps) |
Kind: instance property of PUPHub
Overrides: name
Read only: true
Properties
Name | Type | Description |
---|---|---|
name | string |
Name of the hub |
Kind: instance property of PUPHub
Overrides: uuid
Read only: true
Properties
Name | Type | Description |
---|---|---|
uuid | string |
UUID of the hub |
Kind: instance property of PUPHub
Overrides: rssi
Read only: true
Properties
Name | Type | Description |
---|---|---|
rssi | number |
Signal strength of the hub |
Kind: instance property of PUPHub
Overrides: batteryLevel
Read only: true
Properties
Name | Type | Description |
---|---|---|
batteryLevel | number |
Battery level of the hub (Percentage between 0-100) |
Set the motor speed on a given port.
Kind: instance method of PUPHub
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
Param | Type | Description |
---|---|---|
port | string |
|
speed | number | Array.<number> |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
[time] | number |
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
Ramp the motor speed on a given port.
Kind: instance method of PUPHub
Returns: Promise
- Resolved upon successful completion of command.
Param | Type | Description |
---|---|---|
port | string |
|
fromSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
toSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
time | number |
How long the ramp should last (in milliseconds). |
Set the light brightness on a given port.
Kind: instance method of PUPHub
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
Param | Type | Description |
---|---|---|
port | string |
|
brightness | number |
Brightness value between 0-100 (0 is off) |
[time] | number |
How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely. |
Set the name of the Hub.
Kind: instance method of PUPHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
name | string |
New name of the hub (14 characters or less, ASCII only). |
Set the color of the LED on the Hub via a color value.
Kind: instance method of PUPHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
color | number |
A number representing one of the LED color consts. |
Set the color of the LED on the Hub via RGB values.
Kind: instance method of PUPHub
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
red | number |
green | number |
blue | number |
Connect to the Hub.
Kind: instance method of PUPHub
Overrides: connect
Returns: Promise
- Resolved upon successful connect.
Disconnect the Hub.
Kind: instance method of PUPHub
Overrides: disconnect
Returns: Promise
- Resolved upon successful disconnect.
Subscribe to sensor notifications on a given port.
Kind: instance method of PUPHub
Overrides: subscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
port | string |
|
[mode] | number |
The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
Unsubscribe to sensor notifications on a given port.
Kind: instance method of PUPHub
Overrides: unsubscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
port | string |
Sleep a given amount of time.
This is a helper method to make it easier to add delays into a chain of commands.
Kind: instance method of PUPHub
Overrides: sleep
Returns: Promise
- Resolved after the delay is finished.
Param | Type | Description |
---|---|---|
delay | number |
How long to sleep (in milliseconds). |
Wait until a given list of concurrently running commands are complete.
This is a helper method to make it easier to wait for concurrent commands to complete.
Kind: instance method of PUPHub
Overrides: wait
Returns: Promise
- Resolved after the commands are finished.
Param | Type | Description |
---|---|---|
commands | Array.<Promise.<any>> |
Array of executing commands. |
Emits when a button is pressed.
Kind: event emitted by PUPHub
Param | Type | Description |
---|---|---|
button | string |
|
state | number |
A number representing one of the button state consts. |
Emits when a distance sensor is activated.
Kind: event emitted by PUPHub
Param | Type | Description |
---|---|---|
port | string |
|
distance | number |
Distance, in millimeters. |
Emits when a color sensor is activated.
Kind: event emitted by PUPHub
Param | Type | Description |
---|---|---|
port | string |
|
color | number |
A number representing one of the LED color consts. |
Emits when a tilt sensor is activated.
Kind: event emitted by PUPHub
Param | Type | Description |
---|---|---|
port | string |
If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used. |
x | number |
|
y | number |
Emits when a motor or sensor is attached to the Hub.
Kind: event emitted by PUPHub
Overrides: attach
Param | Type | Description |
---|---|---|
port | string |
|
type | number |
A number representing one of the peripheral consts. |
Emits when an attached motor or sensor is detached from the Hub.
Kind: event emitted by PUPHub
Overrides: detach
Param | Type |
---|---|
port | string |
Kind: global class
Extends: LPF2Hub
, Hub
- PUPRemote ⇐
LPF2Hub
- new PUPRemote()
- .current
- .name
- .uuid
- .rssi
- .batteryLevel
- .setLEDColor(color) ⇒
Promise
- .setLEDRGB(red, green, blue) ⇒
Promise
- .setName(name) ⇒
Promise
- .connect() ⇒
Promise
- .disconnect() ⇒
Promise
- .subscribe(port, [mode]) ⇒
Promise
- .unsubscribe(port) ⇒
Promise
- .sleep(delay) ⇒
Promise
- .wait(commands) ⇒
Promise
- "button" (button, state)
The PUPRemote is emitted if the discovered device is a Powered UP Remote.
Kind: instance property of PUPRemote
Read only: true
Properties
Name | Type | Description |
---|---|---|
current | number |
Current usage of the hub (Amps) |
Kind: instance property of PUPRemote
Overrides: name
Read only: true
Properties
Name | Type | Description |
---|---|---|
name | string |
Name of the hub |
Kind: instance property of PUPRemote
Overrides: uuid
Read only: true
Properties
Name | Type | Description |
---|---|---|
uuid | string |
UUID of the hub |
Kind: instance property of PUPRemote
Overrides: rssi
Read only: true
Properties
Name | Type | Description |
---|---|---|
rssi | number |
Signal strength of the hub |
Kind: instance property of PUPRemote
Overrides: batteryLevel
Read only: true
Properties
Name | Type | Description |
---|---|---|
batteryLevel | number |
Battery level of the hub (Percentage between 0-100) |
Set the color of the LED on the Remote via a color value.
Kind: instance method of PUPRemote
Overrides: setLEDColor
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
color | number |
A number representing one of the LED color consts. |
Set the color of the LED on the Hub via RGB values.
Kind: instance method of PUPRemote
Overrides: setLEDRGB
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
red | number |
green | number |
blue | number |
Set the name of the Hub.
Kind: instance method of PUPRemote
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
name | string |
New name of the hub (14 characters or less, ASCII only). |
Connect to the Hub.
Kind: instance method of PUPRemote
Overrides: connect
Returns: Promise
- Resolved upon successful connect.
Disconnect the Hub.
Kind: instance method of PUPRemote
Overrides: disconnect
Returns: Promise
- Resolved upon successful disconnect.
Subscribe to sensor notifications on a given port.
Kind: instance method of PUPRemote
Overrides: subscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
port | string |
|
[mode] | number |
The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
Unsubscribe to sensor notifications on a given port.
Kind: instance method of PUPRemote
Overrides: unsubscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
port | string |
Sleep a given amount of time.
This is a helper method to make it easier to add delays into a chain of commands.
Kind: instance method of PUPRemote
Overrides: sleep
Returns: Promise
- Resolved after the delay is finished.
Param | Type | Description |
---|---|---|
delay | number |
How long to sleep (in milliseconds). |
Wait until a given list of concurrently running commands are complete.
This is a helper method to make it easier to wait for concurrent commands to complete.
Kind: instance method of PUPRemote
Overrides: wait
Returns: Promise
- Resolved after the commands are finished.
Param | Type | Description |
---|---|---|
commands | Array.<Promise.<any>> |
Array of executing commands. |
Emits when a button is pressed.
Kind: event emitted by PUPRemote
Param | Type | Description |
---|---|---|
button | string |
|
state | number |
A number representing one of the button state consts. |
Kind: global class
Extends: LPF2Hub
, Hub
- DuploTrainBase ⇐
LPF2Hub
- new DuploTrainBase()
- .current
- .name
- .uuid
- .rssi
- .batteryLevel
- .setLEDColor(color) ⇒
Promise
- .setMotorSpeed(port, speed, [time]) ⇒
Promise
- .playSound(sound) ⇒
Promise
- .rampMotorSpeed(port, fromSpeed, toSpeed, time) ⇒
Promise
- .setName(name) ⇒
Promise
- .setLEDRGB(red, green, blue) ⇒
Promise
- .connect() ⇒
Promise
- .disconnect() ⇒
Promise
- .subscribe(port, [mode]) ⇒
Promise
- .unsubscribe(port) ⇒
Promise
- .sleep(delay) ⇒
Promise
- .wait(commands) ⇒
Promise
- "color" (port, color)
- "speed" (port, speed)
The DuploTrainBase is emitted if the discovered device is a Duplo Train Base.
Kind: instance property of DuploTrainBase
Read only: true
Properties
Name | Type | Description |
---|---|---|
current | number |
Current usage of the hub (Amps) |
Kind: instance property of DuploTrainBase
Overrides: name
Read only: true
Properties
Name | Type | Description |
---|---|---|
name | string |
Name of the hub |
Kind: instance property of DuploTrainBase
Overrides: uuid
Read only: true
Properties
Name | Type | Description |
---|---|---|
uuid | string |
UUID of the hub |
Kind: instance property of DuploTrainBase
Overrides: rssi
Read only: true
Properties
Name | Type | Description |
---|---|---|
rssi | number |
Signal strength of the hub |
Kind: instance property of DuploTrainBase
Overrides: batteryLevel
Read only: true
Properties
Name | Type | Description |
---|---|---|
batteryLevel | number |
Battery level of the hub (Percentage between 0-100) |
Set the color of the LED on the train via a color value.
Kind: instance method of DuploTrainBase
Overrides: setLEDColor
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
color | number |
A number representing one of the LED color consts. |
Set the motor speed on a given port.
Kind: instance method of DuploTrainBase
Returns: Promise
- Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
Param | Type | Description |
---|---|---|
port | string |
|
speed | number | Array.<number> |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds. |
[time] | number |
How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. |
Play a built-in train sound.
Kind: instance method of DuploTrainBase
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
sound | number |
A number representing one of the Train Base sound consts. |
Ramp the motor speed on a given port.
Kind: instance method of DuploTrainBase
Returns: Promise
- Resolved upon successful completion of command.
Param | Type | Description |
---|---|---|
port | string |
|
fromSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
toSpeed | number |
For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. |
time | number |
How long the ramp should last (in milliseconds). |
Set the name of the Hub.
Kind: instance method of DuploTrainBase
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
name | string |
New name of the hub (14 characters or less, ASCII only). |
Set the color of the LED on the Hub via RGB values.
Kind: instance method of DuploTrainBase
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
red | number |
green | number |
blue | number |
Connect to the Hub.
Kind: instance method of DuploTrainBase
Overrides: connect
Returns: Promise
- Resolved upon successful connect.
Disconnect the Hub.
Kind: instance method of DuploTrainBase
Overrides: disconnect
Returns: Promise
- Resolved upon successful disconnect.
Subscribe to sensor notifications on a given port.
Kind: instance method of DuploTrainBase
Overrides: subscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type | Description |
---|---|---|
port | string |
|
[mode] | number |
The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen. |
Unsubscribe to sensor notifications on a given port.
Kind: instance method of DuploTrainBase
Overrides: unsubscribe
Returns: Promise
- Resolved upon successful issuance of command.
Param | Type |
---|---|
port | string |
Sleep a given amount of time.
This is a helper method to make it easier to add delays into a chain of commands.
Kind: instance method of DuploTrainBase
Overrides: sleep
Returns: Promise
- Resolved after the delay is finished.
Param | Type | Description |
---|---|---|
delay | number |
How long to sleep (in milliseconds). |
Wait until a given list of concurrently running commands are complete.
This is a helper method to make it easier to wait for concurrent commands to complete.
Kind: instance method of DuploTrainBase
Overrides: wait
Returns: Promise
- Resolved after the commands are finished.
Param | Type | Description |
---|---|---|
commands | Array.<Promise.<any>> |
Array of executing commands. |
Emits when a color sensor is activated.
Kind: event emitted by DuploTrainBase
Param | Type | Description |
---|---|---|
port | string |
|
color | number |
A number representing one of the LED color consts. |
Emits on a speed change.
Kind: event emitted by DuploTrainBase
Param | Type |
---|---|
port | string |
speed | number |