コード例 #1
0
        public async Task turnAround()
        {
            //await Task.Delay(100);
            //float currentAngle = GyroSensor.getSIValue();

            //while (gyroSensor.getSIValue() >= currentAngle - 360)
            //{
            //    MainBrick.Brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.A, -27, 10, false);
            //    MainBrick.Brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.D, 27, 10, false);
            //    await MainBrick.Brick.BatchCommand.SendCommandAsync();
            //    await Task.Delay(100);
            //}

            await Task.Delay(100);

            // store current angle
            float currentAngle = GyroSensor.getSIValue();

            while (gyroSensor.getSIValue() >= currentAngle - 360)
            {
                MainBrick.Brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.A, -30, 10, false);
                MainBrick.Brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.D, 30, 10, false);
                await MainBrick.Brick.BatchCommand.SendCommandAsync();

                await Task.Delay(10);
            }
        }
コード例 #2
0
 public LegoBot()
 {
     mainBrick        = new MainBrick();
     gyroSensor       = new GyroSensor();
     ultrasonicSensor = new UltrasonicSensor();
     colourSensor     = new ColourSensor();
     motor            = new Motor();
 }
コード例 #3
0
        public async Task stepMotor()
        {
            await Task.Delay(100);

            // store current angle
            float currentAngle = GyroSensor.getSIValue();

            while (gyroSensor.getSIValue() >= currentAngle - 90)
            {
                MainBrick.Brick.BatchCommand.StepMotorAtPower(OutputPort.A, -25, 1, false);
                MainBrick.Brick.BatchCommand.StepMotorAtPower(OutputPort.D, 25, 1, false);
                await MainBrick.Brick.BatchCommand.SendCommandAsync();

                await Task.Delay(10);
            }
        }
コード例 #4
0
        public async Task TurnLeft()
        {
            // delay it by few milli sec
            await Task.Delay(100);

            // store current angle
            float currentAngle = GyroSensor.getSIValue();

            while (gyroSensor.getSIValue() >= currentAngle - 90)
            {
                MainBrick.Brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.A, -25, 10, false);
                MainBrick.Brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.D, 25, 10, false);
                await MainBrick.Brick.BatchCommand.SendCommandAsync();

                await Task.Delay(10);
            }
        }