コード例 #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();
    }