PassiveMotor

LEGO® TECHNIC™ motors which do not have an integrated rotation sensor (encoder).

Passive Motors

LEGO® Train motor 88011

BrickLink item 88011

The LEGO Train Motor

class buildhat.PassiveMotor(port)

Passive Motor device

Parameters

port – Port of device

Raises

DeviceError – Occurs if there is no passive motor attached to port

bias(bias)

Bias motor

Parameters

bias – Value 0 to 1

Raises

MotorError – Occurs if invalid bias value 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

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 sensor

on()

Turn on sensor

plimit(plimit)

Limit power

Parameters

plimit – Value 0 to 1

Raises

MotorError – Occurs if invalid plimit value passed

reverse()

Reverse polarity

select()

Request data from mode

Raises

DeviceError – Occurs if device not in valid mode

set_default_speed(default_speed)

Set the default speed of the motor

Parameters

default_speed – Speed ranging from -100 to 100

Raises

MotorError – Occurs if invalid speed passed

start(speed=None)

Start motor

Parameters

speed – Speed ranging from -100 to 100

Raises

MotorError – Occurs if invalid speed passed

stop()

Stop motor

property typeid

Type ID of device

Returns

Type ID

property typeidcur

Type ID currently present

Returns

Type ID

Example

"""Passive motor example"""

import time

from buildhat import PassiveMotor

motor = PassiveMotor('A')

print("Start motor")
motor.start()
time.sleep(3)
print("Stop motor")
motor.stop()