Manipulation of Lego Mindstorms NXT device.

Namespace:  AForge.Robotics.Lego
Assembly:  AForge.Robotics.Lego (in AForge.Robotics.Lego.dll) Version: 2.2.5.0 (2.2.5.0)

Syntax

C#
public class NXTBrick

Remarks

The class allows to manipulate with Lego Mindstorms NXT device, setting/getting its motors' state, getting information about sensors' values and retrieving generic information about the NXT brick.

Note:Only communication through Bluetooth (virtual serial port) is supported at this point.

Sample usage:

CopyC#
// create an instance of NXT brick
NXTBrick nxt = new NXTBrick( );
// connect to the device
if ( nxt.Connect( "COM8" ) )
{
    // run motor A
    NXTBrick.MotorState motorState = new NXTBrick.MotorState( );

    motorState.Power      = 70;
    motorState.TurnRatio  = 50;
    motorState.Mode       = NXTBrick.MotorMode.On;
    motorState.Regulation = NXTBrick.MotorRegulationMode.Idle;
    motorState.RunState   = NXTBrick.MotorRunState.Running;
    motorState.TachoLimit = 1000;

    nxt.SetMotorState( NXTBrick.Motor.A, motorState );

    // get input value from the first sensor
    NXTBrick.SensorValues sensorValues;

    if ( nxt.GetSensorValue( NXTBrick.Sensor.First, out sensorValues ) )
    {
        // ...
    }
    // ...
}

Inheritance Hierarchy

System..::.Object
  AForge.Robotics.Lego..::.NXTBrick

See Also