# Classes

##

### Classes

BoostMoveHub
DuploTrainBase
Hub
LPF2Hub
PoweredUP
PUPHub
PUPRemote
WeDo2SmartHub

### Events

#### attach

  Emits when a motor or sensor is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |
  `type` | DeviceType |

  Inherited From:
    - Hub#event:attach
  Overrides:
    - Hub#event:attach
  Source:
    - hub.js, line 265

#### button

  Emits when a button is pressed.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - lpf2hub.js, line 171

#### color

  Emits when a color sensor is activated.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:color
  Source:
    - lpf2hub.js, line 271

#### colorAndDistance

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

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:colorAndDistance
  Source:
    - lpf2hub.js, line 287

#### detach

  Emits when an attached motor or sensor is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Inherited From:
    - Hub#event:detach
  Overrides:
    - Hub#event:detach
  Source:
    - hub.js, line 277

#### distance

  Emits when a distance sensor is activated.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:distance
  Source:
    - lpf2hub.js, line 261

#### rotate

  Emits when a rotation sensor is activated.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:rotate
  Source:
    - lpf2hub.js, line 316

#### tilt

  Emits when a tilt sensor is activated.

  ##### Parameters:

  Name | 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 |

  Inherited From:
    - LPF2Hub#event:tilt
  Source:
    - lpf2hub.js, line 304

#### color

  Emits when a color sensor is activated.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:color
  Source:
    - lpf2hub.js, line 271

#### speed

  Emits on a speed change.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:speed
  Source:
    - lpf2hub.js, line 364

#### attach

  Emits when a motor or sensor is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |
  `type` | DeviceType |

  Source:
    - hub.js, line 265

#### detach

  Emits when an attached motor or sensor is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Source:
    - hub.js, line 277

#### attach

  Emits when a motor or sensor is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |
  `type` | DeviceType |

  Inherited From:
    - Hub#event:attach
  Source:
    - hub.js, line 265

#### button

  Emits when a button is pressed.

  ##### Parameters:

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

  Source:
    - lpf2hub.js, line 171

#### color

  Emits when a color sensor is activated.

  ##### Parameters:

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

  Source:
    - lpf2hub.js, line 271

#### colorAndDistance

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

  ##### Parameters:

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

  Source:
    - lpf2hub.js, line 287

#### detach

  Emits when an attached motor or sensor is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Inherited From:
    - Hub#event:detach
  Source:
    - hub.js, line 277

#### distance

  Emits when a distance sensor is activated.

  ##### Parameters:

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

  Source:
    - lpf2hub.js, line 261

#### rotate

  Emits when a rotation sensor is activated.

  ##### Parameters:

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

  Source:
    - lpf2hub.js, line 316

#### speed

  Emits on a speed change.

  ##### Parameters:

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

  Source:
    - lpf2hub.js, line 364

#### tilt

  Emits when a tilt sensor is activated.

  ##### Parameters:

  Name | 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 |

  Source:
    - lpf2hub.js, line 304

#### discover

  Emits when a Powered UP Hub device is found.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `hub` | WeDo2SmartHub | BoostMoveHub | PUPHub | PUPRemote | DuploTrainBase |

  Source:
    - poweredup.js, line 146

#### attach

  Emits when a motor or sensor is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |
  `type` | DeviceType |

  Inherited From:
    - Hub#event:attach
  Overrides:
    - Hub#event:attach
  Source:
    - hub.js, line 265

#### button

  Emits when a button is pressed.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - lpf2hub.js, line 171

#### color

  Emits when a color sensor is activated.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:color
  Source:
    - lpf2hub.js, line 271

#### colorAndDistance

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

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:colorAndDistance
  Source:
    - lpf2hub.js, line 287

#### detach

  Emits when an attached motor or sensor is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Inherited From:
    - Hub#event:detach
  Overrides:
    - Hub#event:detach
  Source:
    - hub.js, line 277

#### distance

  Emits when a distance sensor is activated.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:distance
  Source:
    - lpf2hub.js, line 261

#### tilt

  Emits when a tilt sensor is activated.

  ##### Parameters:

  Name | 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 |

  Inherited From:
    - LPF2Hub#event:tilt
  Source:
    - lpf2hub.js, line 304

#### button

  Emits when a button is pressed.

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:button
  Source:
    - lpf2hub.js, line 171

#### colorAndDistance

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

  ##### Parameters:

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

  Inherited From:
    - LPF2Hub#event:colorAndDistance
  Source:
    - lpf2hub.js, line 287

#### attach

  Emits when a motor or sensor is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |
  `type` | DeviceType |

  Inherited From:
    - Hub#event:attach
  Source:
    - hub.js, line 265

#### button

  Emits when a button is pressed.

  ##### Parameters:

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

  Source:
    - wedo2smarthub.js, line 292

#### color

  Emits when a color sensor is activated.

  ##### Parameters:

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

  Source:
    - wedo2smarthub.js, line 337

#### detach

  Emits when an attached motor or sensor is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | string |

  Inherited From:
    - Hub#event:detach
  Source:
    - hub.js, line 277

#### distance

  Emits when a distance sensor is activated.

  ##### Parameters:

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

  Source:
    - wedo2smarthub.js, line 326

#### rotate

  Emits when a rotation sensor is activated.

  ##### Parameters:

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

  Source:
    - wedo2smarthub.js, line 367

#### tilt

  Emits when a tilt sensor is activated.

  ##### Parameters:

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

  Source:
    - wedo2smarthub.js, line 355

#### Search results