示例#1
0
    private static string UID = "9yEBJVAgcoj"; // Change to your UID

    #endregion Fields

    #region Methods

    static void Main()
    {
        IPConnection ipcon = new IPConnection(HOST, PORT); // Create connection to brickd
        stepper = new BrickStepper(UID); // Create device object
        ipcon.AddDevice(stepper); // Add device to IP connection
        // Don't use device before it is added to a connection

        // Register "position reached callback" to ReachedCB
        // ReachedCB will be called every time a position set with
        // SetSteps or SetTargetPosition is reached
        stepper.RegisterCallback(new BrickStepper.PositionReached(ReachedCB));

        stepper.Enable();
        stepper.SetSteps(1); // Drive one step forward to get things going

        System.Console.WriteLine("Press ctrl+c to exit");
        ipcon.JoinThread();
    }
    private static string UID = "XXYYZZ"; // Change XXYYZZ to the UID of your Stepper Brick

    #endregion Fields

    #region Methods

    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickStepper stepper = new BrickStepper(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT); // Connect to brickd
        // Don't use device before ipcon is connected

        // Register position reached callback to function PositionReachedCB
        stepper.PositionReached += PositionReachedCB;

        stepper.Enable(); // Enable motor power
        stepper.SetSteps(1); // Drive one step forward to get things going

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        stepper.Disable();
        ipcon.Disconnect();
    }
    private static string UID = "XXYYZZ"; // Change XXYYZZ to the UID of your Stepper Brick

    #endregion Fields

    #region Methods

    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickStepper stepper = new BrickStepper(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT); // Connect to brickd
        // Don't use device before ipcon is connected

        stepper.SetMotorCurrent(800); // 800mA
        stepper.SetStepMode(8); // 1/8 step mode
        stepper.SetMaxVelocity(2000); // Velocity 2000 steps/s

        // Slow acceleration (500 steps/s^2),
        // Fast deacceleration (5000 steps/s^2)
        stepper.SetSpeedRamping(500, 5000);

        stepper.Enable(); // Enable motor power
        stepper.SetSteps(60000); // Drive 60000 steps forward

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        stepper.Disable();
        ipcon.Disconnect();
    }