Light¶
The LEGO® 88005 Powered Up Light features 2 LED lights, connecting wire and connection point for LEGO® Powered Up components.
- class buildhat.Light(port)¶
Use on()/off() functions to turn lights on/off
- Parameters:
port – Port of device
- Raises:
DeviceError – Occurs if there is no light attached to port
- brightness(brightness)¶
Brightness of LEDs
- Parameters:
brightness – Brightness argument 0 to 100
- Raises:
LightError – Occurs if invalid brightness passed
- callback(func)¶
Set callback function
- Parameters:
func – Callback function
- property connected¶
Whether device is connected or not
- Returns:
Connection status
- static desc_for_id(typeid)¶
Translate integer type id to something more descriptive than the device name
- Parameters:
typeid – Type of device
- Returns:
Description of device
- property description¶
Device on port info
- Returns:
Device description
- deselect()¶
Unselect data from mode
- get()¶
Extract information from device
- Returns:
Data from device
- Raises:
DeviceError – Occurs if device not in valid mode
- property interval¶
Interval between data points in milliseconds
- Getter:
Gets interval
- Setter:
Sets interval
- Returns:
Device interval
- Return type:
int
- isconnected()¶
Whether it is connected or not
- Raises:
DeviceError – Occurs if device no longer the same
- mode(modev)¶
Set combimode or simple mode
- Parameters:
modev – List of tuples for a combimode, or integer for simple mode
- property name¶
Determine name of device on port
- Returns:
Device name
- static name_for_id(typeid)¶
Translate integer type id to device name (python class)
- Parameters:
typeid – Type of device
- Returns:
Name of device
- off()¶
Turn off lights
- on()¶
Turn on sensor
- reverse()¶
Reverse polarity
- select()¶
Request data from mode
- Raises:
DeviceError – Occurs if device not in valid mode
- property typeid¶
Type ID of device
- Returns:
Type ID
- property typeidcur¶
Type ID currently present
- Returns:
Type ID
Example¶
"""Example turning on/off LED lights"""
from time import sleep
from buildhat import Light
light = Light('A')
light.on()
sleep(1)
light.off()