Ejemplo n.º 1
0
        //EV3IRSensor
        private async Task TestIRSensor()
        {
            EV3IRSensor ultra = new EV3IRSensor(brick, BrickPortSensor.PORT_S4, IRMode.Remote);

            int count = 0;

            while (count < 100)
            {
                Debug.WriteLine(string.Format("NXT ultra, Remote: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              ultra.Value, ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                await Task.Delay(300);

                count++;
            }
            ultra.Mode = IRMode.Proximity;
            count      = 0;
            while (count < 10)
            {
                Debug.WriteLine(string.Format("NXT ultra, Remote: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              ultra.Value, ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                await Task.Delay(300);

                count++;
            }
            ultra.Mode = IRMode.Seek;
            count      = 0;
            while (count < 10)
            {
                Debug.WriteLine(string.Format("NXT ultra, Remote: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              ultra.Value, ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                await Task.Delay(300);

                count++;
            }
        }
Ejemplo n.º 2
0
        //EV3IRSensor
        private async Task TestIRSensor()
        {
            EV3IRSensor ultra = new EV3IRSensor(BrickPortSensor.PORT_S4, IRMode.Remote);

            for (int i = 0; i < ultra.NumberOfModes(); i++)
            {
                int count = 0;
                while (count < 100)
                {
                    Debug.WriteLine(string.Format("NXT ultra, Distance: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                                  ultra.ReadBeaconLocation(), ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                    await Task.Delay(300);
                }
                ultra.SelectNextMode();
            }
        }