乐高机器人®组件

« 返回首页

乐高机器人®组件

目录:

EV3颜色传感器

EV3 component icon

A component that provides a high-level interface to a color sensor on a LEGO MINDSTORMS EV3 robot.

属性

AboveRangeEventEnabled
Specifies whether the AboveRange event should fire when the light level goes above the TopOfRange.
BelowRangeEventEnabled
Specifies whether the BelowRange event should fire when the light level goes below the BottomOfRange.
BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
BottomOfRange
Specifies the bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
ColorChangedEventEnabled
Specifies whether the ColorChanged event should fire when the DetectColor property is set to True and the detected color changes
Mode
The current mode of the sensor. One of: Reflected: Senses the current light level including light reflected by the sensor. Ambient: Senses the current light level not including light reflected by the sensor. Color: Senses the color the sensor is pointing at.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.
TopOfRange
Specifies the top of the range used for the BelowRange, WithinRange, and AboveRange events.
WithinRangeEventEnabled
Specifies whether the WithinRange event should fire when the light level goes between the BottomOfRange and the TopOfRange.

事件

AboveRange()
Light level has gone above the range.
BelowRange()
Light level has gone below the range.
ColorChanged(colorCode,colorName)
Called when the detected color has changed.
WithinRange()
Light level has gone within the range.

方法

GetColorCode()
It returns the color code for the detected color.
GetColorName()
Returns the name of the detected color.
GetLightLevel()
It returns the light level in percentage.

EV3指令发送器

EV3 component icon

A component that provides a low-level interface to a LEGO MINDSTORMS EV3 robot, with functions to send system or direct commands to EV3 robots.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.

事件

方法

GetBatteryCurrent()
Get the battery current.
GetBatteryVoltage()
Get the battery voltage.
GetFirmwareBuild()
Get the firmware build on EV3.
GetFirmwareVersion()
Get the firmware version on EV3.
GetHardwareVersion()
Get the hardware version of EV3.
GetOSBuild()
Get the OS build on EV3.
GetOSVersion()
Get the OS version on EV3.
KeepAlive(minutes)
Keep the EV3 brick from shutdown for a period of time.

EV3陀螺仪传感器

EV3 component icon

A component that provides a high-level interface to a gyro sensor on a LEGO MINDSTORMS EV3 robot.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
Mode
Returns the mode of the sensor.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.
SensorValueChangedEventEnabled
Returns whether the SensorValueChanged event should fire when the sensor value changed.

事件

SensorValueChanged(sensorValue)
Called then the sensor value changed.

方法

GetSensorValue()
Returns the current angle or rotation speed based on current mode, or -1 if the value cannot be read from sensor.

EV3马达

EV3 component icon

A component that provides both high- and low-level interfaces to control the motors on LEGO MINDSTORMS EV3.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
EnableSpeedRegulation
Returns whether to keep motor rotation at constant speed.
MotorPorts
Specifies the motor port.
ReverseDirection
Returns if the direction of the motors is reversed.
StopBeforeDisconnect
Specifies whether to stop the drive motors before disconnecting.
TachoCountChangedEventEnabled
Returns whether the TachoCountChanged event should fire when the motor angle is increaing.
WheelDiameter
Returns the diameter of the wheels attached on motors.

事件

TachoCountChanged(tachoCount)
Called when the tacho count has changed.

方法

GetTachoCount()
Get the current tacho count.
ResetTachoCount()
Set the current tacho count to zero.
RotateInDistance(power,distance,useBrake)
Rotate the motors in a distance.
RotateInDuration(power,milliseconds,useBrake)
Rotate the motors in a period of time.
RotateInTachoCounts(power,tachoCounts,useBrake)
Rotate the motors in a number of tacho counts.
RotateIndefinitely(power)
Start to rotate the motors.
RotateSyncInDistance(power,distance,turnRatio,useBrake)
Rotate the motors at the same speed for a distance in cm.
RotateSyncInDuration(power,milliseconds,turnRatio,useBrake)
Rotate the motors at the same speed in a period of time.
RotateSyncInTachoCounts(power,tachoCounts,turnRatio,useBrake)
Rotate the motors at the same speed in a number of tacho counts.
RotateSyncIndefinitely(power,turnRatio)
Start to rotate the motors at the same speed.
Stop(useBrake)
Stop the motors of the robot.
ToggleDirection()
Toggle the direction of motors.

EV3声音

EV3 component icon

A component that provides a high-level interface to a LEGO MINDSTORMS EV3 robot, which provides sound functionalities.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.

事件

方法

PlayTone(volume,frequency,milliseconds)
Make the robot play a tone.
StopSound()
Stop any sound on the robot.

EV3接触传感器

EV3 component icon

A component that provides a high-level interface to a touch sensor on a LEGO MINDSTORMS EV3 robot.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
PressedEventEnabled
Returns whether the Pressed event should fire when the touch sensor is pressed.
ReleasedEventEnabled
Specifies whether the Released event should fire when the touch sensor is released.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.

事件

Pressed()
Called when the touch sensor is pressed.
Released()
Called when the touch sensor is pressed.

方法

IsPressed()
Returns true if the touch sensor is pressed.

EV3绘图

EV3 component icon

A component that provides a high-level interface to a LEGO MINDSTORMS EV3 robot, which provides graphic functionalities.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.

事件

方法

DrawCircle(color,x,y,radius,fill)
Draw a circle on the screen.
DrawIcon(color,x,y,type,no)
Draw a built-in icon on screen.
DrawLine(color,x1,y1,x2,y2)
Draw a line on the screen.
DrawPoint(color,x,y)
Draw a point on the screen.
DrawRect(color,x,y,width,height,fill)
Draw a rectangle on the screen.
FillScreen(color)
Fill the screen with a color.

EV3超声波传感器

EV3 component icon

A component that provides a high-level interface to an ultrasonic sensor on a LEGO MINDSTORMS EV3 robot.

属性

AboveRangeEventEnabled
Specifies whether the AboveRange event should fire when the distance goes above the TopOfRange.
BelowRangeEventEnabled
Specifies whether the BelowRange event should fire when the distance goes below the BottomOfRange.
BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
BottomOfRange
Specifies the bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.
TopOfRange
Specifies the top of the range used for the BelowRange, WithinRange, and AboveRange events.
Unit
Returns the unit of distance.
WithinRangeEventEnabled
Specifies whether the WithinRange event should fire when the distance goes between the BottomOfRange and the TopOfRange.

事件

AboveRange()
Called when the detected distance has gone above the range.
BelowRange()
Called when the detected distance has gone below the range.
WithinRange()
Called when the detected distance has gone within the range.

方法

GetDistance()
Returns the current distance in centimeters as a value between 0 and 254, or -1 if the distance can not be read.

Nxt颜色传感器

NXT component icon

A component that provides a high-level interface to a color sensor on a LEGO MINDSTORMS NXT robot.

属性

AboveRangeEventEnabled
Specifies whether the AboveRange event should fire when the DetectColor property is set to False and the light level goes above the TopOfRange.
BelowRangeEventEnabled
Specifies whether the BelowRange event should fire when the DetectColor property is set to False and the light level goes below the BottomOfRange.
BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
BottomOfRange
Specifies the bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
ColorChangedEventEnabled
Specifies whether the ColorChanged event should fire when the DetectColor property is set to True and the detected color changes
DetectColor
Specifies whether the sensor should detect color light. True indicates that the sensor should detect color; False indicates that the sensor should detect light.
GenerateColor
Specifies the color that should generated by the sensor. Only None, Red, Green, or Blue are valid values. The sensor will not generate color when the DetectColor property is set to True.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.
TopOfRange
Specifies the top of the range used for the BelowRange, WithinRange, and AboveRange events.
WithinRangeEventEnabled
Specifies whether the WithinRange event should fire when the DetectColor property is set to False and the light level goes between the BottomOfRange and the TopOfRange.

事件

AboveRange()
Light level has gone above the range. The AboveRange event will not occur if the DetectColor property is set to True or if the AboveRangeEventEnabled property is set to False.
BelowRange()
Light level has gone below the range. The BelowRange event will not occur if the DetectColor property is set to True or if the BelowRangeEventEnabled property is set to False.
ColorChanged(color)
Detected color has changed. The ColorChanged event will not occur if the DetectColor property is set to False or if the ColorChangedEventEnabled property is set to False.
WithinRange()
Light level has gone within the range. The WithinRange event will not occur if the DetectColor property is set to True or if the WithinRangeEventEnabled property is set to False.

方法

GetColor()
Returns the current detected color, or the color None if the color can not be read or if the DetectColor property is set to False.
GetLightLevel()
Returns the current light level as a value between 0 and 1023, or -1 if the light level can not be read or if the DetectColor property is set to True.

Nxt指令发送器

NXT component icon

A component that provides a low-level interface to a LEGO MINDSTORMS NXT robot, with functions to send NXT Direct Commands.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.

事件

方法

DeleteFile(fileName)
Delete a file on the robot.
DownloadFile(source,destination)
Download a file to the robot.

See MediaUtil’s determineMediaSource for information about what a path can be.

GetBatteryLevel()
Get the battery level for the robot. Returns the voltage in millivolts.
GetBrickName()
Get the brick name of the robot.
GetCurrentProgramName()
Get the name of currently running program on the robot.
GetFirmwareVersion()
Get the firmware and protocol version numbers for the robot as a list where the first element is the firmware version number and the second element is the protocol version number.
GetInputValues(sensorPortLetter)
Reads the values of an input sensor on the robot. Assumes sensor type has been configured via SetInputMode.
GetOutputState(motorPortLetter)
Reads the output state of a motor on the robot.
KeepAlive()
Keep Alive. Returns the current sleep time limit in milliseconds.
ListFiles(wildcard)
Returns a list containing the names of matching files found on the robot.
LsGetStatus(sensorPortLetter)
Returns the count of available bytes to read.
LsRead(sensorPortLetter)
Reads unsigned low speed data from an input sensor on the robot. Assumes sensor type has been configured via SetInputMode.
LsWrite(sensorPortLetter,list,rxDataLength)
Writes low speed data to an input sensor on the robot. Assumes sensor type has been configured via SetInputMode.
MessageRead(mailbox)
Read a message from a mailbox (1-10) on the robot.
MessageWrite(mailbox,message)
Write a message to a mailbox (1-10) on the robot.
PlaySoundFile(fileName)
Play a sound file on the robot.
PlayTone(frequencyHz,durationMs)
Make the robot play a tone.
ResetInputScaledValue(sensorPortLetter)
Reset the scaled value of an input sensor on the robot.
ResetMotorPosition(motorPortLetter,relative)
Reset motor position.
SetBrickName(name)
Set the brick name of the robot.
SetInputMode(sensorPortLetter,sensorType,sensorMode)
Configure an input sensor on the robot.
SetOutputState(motorPortLetter,power,mode,regulationMode,turnRatio,runState,tachoLimit)
Sets the output state of a motor on the robot.
StartProgram(programName)
Start execution of a previously downloaded program on the robot.
StopProgram()
Stop execution of the currently running program on the robot.
StopSoundPlayback()
Stop sound playback.

Nxt电机驱动器

NXT component icon

A component that provides a high-level interface to a LEGO MINDSTORMS NXT robot, with functions that can move and turn the robot.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
DriveMotors
Specifies the motor ports that are used for driving.
StopBeforeDisconnect
Specifies whether to stop the drive motors before disconnecting.
WheelDiameter
Returns the diameter of the wheels used for driving.

事件

方法

MoveBackward(power,distance)
Move the robot backward the given distance, with the specified percentage of maximum power, by powering both drive motors backward.
MoveBackwardIndefinitely(power)
Move the robot backward indefinitely, with the specified percentage of maximum power, by powering both drive motors backward.
MoveForward(power,distance)
Move the robot forward the given distance, with the specified percentage of maximum power, by powering both drive motors forward.
MoveForwardIndefinitely(power)
Move the robot forward indefinitely, with the specified percentage of maximum power, by powering both drive motors forward.
Stop()
Stop the drive motors of the robot.
TurnClockwiseIndefinitely(power)
Turn the robot clockwise indefinitely, with the specified percentage of maximum power, by powering the left drive motor forward and the right drive motor backward.
TurnCounterClockwiseIndefinitely(power)
Turn the robot counterclockwise indefinitely, with the specified percentage of maximum power, by powering the right drive motor forward and the left drive motor backward.

Nxt光线传感器

NXT component icon

A component that provides a high-level interface to a light sensor on a LEGO MINDSTORMS NXT robot.

属性

AboveRangeEventEnabled
Specifies whether the AboveRange event should fire when the light level goes above the TopOfRange.
BelowRangeEventEnabled
Specifies whether the BelowRange event should fire when the light level goes below the BottomOfRange.
BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
BottomOfRange
Specifies the bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
GenerateLight
Specifies whether the light sensor should generate light.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be specified in the Designer.
TopOfRange
Specifies the top of the range used for the BelowRange, WithinRange, and AboveRange events.
WithinRangeEventEnabled
Specifies whether the WithinRange event should fire when the light level goes between the BottomOfRange and the TopOfRange.

事件

AboveRange()
Light level has gone above the range.
BelowRange()
Light level has gone below the range.
WithinRange()
Light level has gone within the range.

方法

GetLightLevel()
Returns the current light level as a value between 0 and 1023, or -1 if the light level can not be read.

Nxt声音传感器

NXT component icon

A component that provides a high-level interface to a sound sensor on a LEGO MINDSTORMS NXT robot.

属性

AboveRangeEventEnabled
Specifies whether the AboveRange event should fire when the sound level goes above the TopOfRange.
BelowRangeEventEnabled
Specifies whether the BelowRange event should fire when the sound level goes below the BottomOfRange.
BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
BottomOfRange
Specifies the bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.
TopOfRange
Specifies the top of the range used for the BelowRange, WithinRange, and AboveRange events.
WithinRangeEventEnabled
Specifies whether the WithinRange event should fire when the sound level goes between the BottomOfRange and the TopOfRange.

事件

AboveRange()
Sound level has gone above the range.
BelowRange()
Sound level has gone below the range.
WithinRange()
Sound level has gone within the range.

方法

GetSoundLevel()
Returns the current sound level as a value between 0 and 1023, or -1 if the sound level can not be read.

Nxt接触传感器

NXT component icon

A component that provides a high-level interface to a touch sensor on a LEGO MINDSTORMS NXT robot.

属性

BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
PressedEventEnabled
Specifies whether the Pressed event should fire when the touch sensor is pressed.
ReleasedEventEnabled
Specifies whether the Released event should fire when the touch sensor is released.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.

事件

Pressed()
Touch sensor has been pressed.
Released()
Touch sensor has been released.

方法

IsPressed()
Returns true if the touch sensor is pressed.

Nxt超声波传感器

NXT component icon

A component that provides a high-level interface to an ultrasonic sensor on a LEGO MINDSTORMS NXT robot.

属性

AboveRangeEventEnabled
Specifies whether the AboveRange event should fire when the distance goes above the TopOfRange.
BelowRangeEventEnabled
Specifies whether the BelowRange event should fire when the distance goes below the BottomOfRange.
BluetoothClient
Specifies the BluetoothClient component that should be used for communication. Must be set in the Designer.
BottomOfRange
Specifies the bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
SensorPort
Specifies the sensor port that the sensor is connected to. Must be set in the Designer.
TopOfRange
Specifies the top of the range used for the BelowRange, WithinRange, and AboveRange events.
WithinRangeEventEnabled
Specifies whether the WithinRange event should fire when the distance goes between the BottomOfRange and the TopOfRange.

事件

AboveRange()
Distance has gone above the range.
BelowRange()
Distance has gone below the range.
WithinRange()
Distance has gone within the range.

方法

GetDistance()
Returns the current distance in centimeters as a value between 0 and 254, or -1 if the distance can not be read.