# node-poweredup Classes

# Classes

##

### Classes

AbsoluteMotor
BaseHub
BasicMotor
BoostMoveHub
ColorDistanceSensor
ControlPlusHub
CurrentSensor
Device
DuploTrainBase
DuploTrainBaseColorSensor
DuploTrainBaseMotor
DuploTrainBaseSpeaker
DuploTraniBaseSpeedometer
Hub
HubLED
Light
LPF2Hub
Mario
MarioAccelerometer
MarioBarcodeSensor
MarioPantsSensor
MediumLinearMotor
MotionSensor
MoveHub
MoveHubMediumLinearMotor
MoveHubTiltSensor
PiezoBuzzer
PUPHub
PUPRemote
RemoteControl
RemoteControlButton
SimpleMediumLinearMotor
TachoMotor
TechnicColorSensor
TechnicDistanceSensor
TechnicForceSensor
TechnicLargeAngularMotor
TechnicLargeLinearMotor
TechnicMediumAngularMotor
TechnicMediumHub
TechnicMediumHubAccelerometerSensor
TechnicMediumHubGyroSensor
TechnicMediumHubTiltSensor
TechnicXLargeLinearMotor
TiltSensor
TrainMotor
VoltageSensor
WeDo2SmartHub

### Events

#### absolute

  Emits when a the motors absolute position is changed.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absolute` | number |

  Source:
    - devices/absolutemotor.js, line 39

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### attach

  Emits when a device is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:attach
  Source:
    - hubs/basehub.js, line 321

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### detach

  Emits when a device is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:detach
  Source:
    - hubs/basehub.js, line 338

#### disconnect

  Emits when the hub is disconnected.

  Inherited From:
    - Hub#event:disconnect
  Source:
    - hubs/basehub.js, line 81

#### color

  Emits when a color sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `color` | Color |

  Source:
    - devices/colordistancesensor.js, line 39

#### colorAndDistance

  A combined color and distance event, emits when the sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `color` | Color |
  `distance` | number | Distance, in millimeters.

  Source:
    - devices/colordistancesensor.js, line 76

#### distance

  Emits when a distance sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `distance` | number | Distance, in millimeters.

  Source:
    - devices/colordistancesensor.js, line 57

#### attach

  Emits when a device is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:attach
  Source:
    - hubs/basehub.js, line 321

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### detach

  Emits when a device is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:detach
  Source:
    - hubs/basehub.js, line 338

#### disconnect

  Emits when the hub is disconnected.

  Inherited From:
    - Hub#event:disconnect
  Source:
    - hubs/basehub.js, line 81

#### current

  Emits when a current change is detected.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `current` | number |

  Source:
    - devices/currentsensor.js, line 51

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### color

  Emits when a color sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `color` | Color |

  Source:
    - devices/duplotrainbasecolorsensor.js, line 39

#### reflect

  Emits when the light reflectivity changes.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `reflect` | number | Percentage, from 0 to 100.

  Source:
    - devices/duplotrainbasecolorsensor.js, line 50

#### rgb

  Emits when the light reflectivity changes.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `red` | number |
  `green` | number |
  `blue` | number |

  Source:
    - devices/duplotrainbasecolorsensor.js, line 62

#### speed

  Emits on a speed change.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `speed` | number |

  Source:
    - devices/duplotrainbasespeedometer.js, line 38

#### attach

  Emits when a device is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Source:
    - hubs/basehub.js, line 321

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### detach

  Emits when a device is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Source:
    - hubs/basehub.js, line 338

#### disconnect

  Emits when the hub is disconnected.

  Source:
    - hubs/basehub.js, line 81

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Source:
    - hubs/lpf2hub.js, line 182

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### accel

  Emits when accelerometer detects movement. Measured in mG.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |
  `z` | number |

  Source:
    - devices/marioaccelerometer.js, line 37

#### gest

  Emits when a gesture is detected

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `gesture` | number |

  Source:
    - devices/marioaccelerometer.js, line 51

#### barcode

  Emits when the barcode sensor sees a barcode.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `id` | number |

  Source:
    - devices/mariobarcodesensor.js, line 37

#### rgb

  Emits when the barcode sensor sees a RGB color.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `r` | number |
  `g` | number |
  `b` | number |

  Source:
    - devices/mariobarcodesensor.js, line 55

#### pants

  Emits when the user changes the pants on Mario.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pants` | number |

  Source:
    - devices/mariopantssensor.js, line 37

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### distance

  Emits when a distance sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `distance` | number | Distance, in millimeters.

  Source:
    - devices/motionsensor.js, line 42

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### tilt

  Emits when a tilt sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |

  Source:
    - devices/movehubtiltsensor.js, line 37

#### attach

  Emits when a device is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:attach
  Source:
    - hubs/basehub.js, line 321

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Overrides:
    - Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### detach

  Emits when a device is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:detach
  Source:
    - hubs/basehub.js, line 338

#### disconnect

  Emits when the hub is disconnected.

  Inherited From:
    - Hub#event:disconnect
  Source:
    - hubs/basehub.js, line 81

#### attach

  Emits when a device is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:attach
  Source:
    - hubs/basehub.js, line 321

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Overrides:
    - Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### detach

  Emits when a device is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:detach
  Source:
    - hubs/basehub.js, line 338

#### disconnect

  Emits when the hub is disconnected.

  Inherited From:
    - Hub#event:disconnect
  Source:
    - hubs/basehub.js, line 81

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### button

  Emits when a button on the remote is pressed or released.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | number |

  Source:
    - devices/remotecontrolbutton.js, line 37

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Source:
    - devices/tachomotor.js, line 43

#### ambient

  Emits when the ambient light changes.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `ambient` | number | Percentage, from 0 to 100.

  Source:
    - devices/techniccolorsensor.js, line 60

#### color

  Emits when a color sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `color` | Color |

  Source:
    - devices/techniccolorsensor.js, line 39

#### reflect

  Emits when the light reflectivity changes.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `reflect` | number | Percentage, from 0 to 100.

  Source:
    - devices/techniccolorsensor.js, line 50

#### distance

  Emits when the detected distance changes (Slow sampling covers 40mm to 2500mm).

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `distance` | number | Distance, from 40 to 2500mm

  Source:
    - devices/technicdistancesensor.js, line 38

#### fastDistance

  Emits when the detected distance changes (Fast sampling covers 50mm to 320mm).

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `fastDistance` | number | Distance, from 50 to 320mm

  Source:
    - devices/technicdistancesensor.js, line 48

#### force

  Emits when force is applied.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `force` | number | Force, in newtons (0-10).

  Source:
    - devices/technicforcesensor.js, line 38

#### tapped

  Emits when the sensor is tapped.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `tapped` | number | How hard the sensor was tapped, from 0-3.

  Source:
    - devices/technicforcesensor.js, line 58

#### touch

  Emits when the sensor is touched.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `touch` | boolean | Touched on/off (boolean).

  Source:
    - devices/technicforcesensor.js, line 48

#### absolute

  Emits when a the motors absolute position is changed.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absolute` | number |

  Inherited From:
    - AbsoluteMotor#event:absolute
  Source:
    - devices/absolutemotor.js, line 39

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### absolute

  Emits when a the motors absolute position is changed.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absolute` | number |

  Inherited From:
    - AbsoluteMotor#event:absolute
  Source:
    - devices/absolutemotor.js, line 39

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### absolute

  Emits when a the motors absolute position is changed.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absolute` | number |

  Inherited From:
    - AbsoluteMotor#event:absolute
  Source:
    - devices/absolutemotor.js, line 39

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 182

#### accel

  Emits when accelerometer detects movement. Measured in mG.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |
  `z` | number |

  Source:
    - devices/technicmediumhubaccelerometersensor.js, line 37

#### gyro

  Emits when gyroscope detects movement. Measured in DPS - degrees per second.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |
  `z` | number |

  Source:
    - devices/technicmediumhubgyrosensor.js, line 37

#### tilt

  Emits when a tilt sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |
  `z` | number |

  Source:
    - devices/technicmediumhubtiltsensor.js, line 37

#### absolute

  Emits when a the motors absolute position is changed.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absolute` | number |

  Inherited From:
    - AbsoluteMotor#event:absolute
  Source:
    - devices/absolutemotor.js, line 39

#### rotate

  Emits when a rotation sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number |

  Inherited From:
    - TachoMotor#event:rotate
  Source:
    - devices/tachomotor.js, line 43

#### tilt

  Emits when a tilt sensor is activated.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |

  Source:
    - devices/tiltsensor.js, line 39

#### voltage

  Emits when a voltage change is detected.

  ##### Type: object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `voltage` | number |

  Source:
    - devices/voltagesensor.js, line 51

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Source:
    - hubs/wedo2smarthub.js, line 182

#### Search results