Example #1
0
        //TODO build test for EV3 Ultra Sound

        private async Task TestNXTUS()
        {
            NXTUltraSonicSensor ultra = new NXTUltraSonicSensor(BrickPortSensor.PORT_S4);

            for (int i = 0; i < ultra.NumberOfModes(); i++)
            {
                int count = 0;
                while (count < 100)
                {
                    Debug.WriteLine(string.Format("NXT US, Distance: {0}, ReadAsString: {1}, Selected mode: {2}",
                                                  ultra.ReadDistance(), ultra.ReadAsString(), ultra.SelectedMode()));
                    await Task.Delay(300);
                }
                ultra.SelectNextMode();
            }
        }
Example #2
0
        private static void TestNXTUS()
        {
            Console.WriteLine("Running NXT Ultrasonic sensor test on port 4. Uses all the modes and read 50 times.");
            NXTUltraSonicSensor ultra = new NXTUltraSonicSensor(_brick, SensorPort.Port4);

            for (int i = 0; i < ultra.NumberOfModes(); i++)
            {
                int count = 0;
                while (count < 50)
                {
                    Console.WriteLine($"NXT Ultrasound, Distance: {ultra.ReadDistance()}, ReadAsString: {ultra.ReadAsString()}, Selected mode: {ultra.SelectedMode()}");
                    Thread.Sleep(2000);
                    count++;
                }

                ultra.SelectNextMode();
            }
        }