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(); } }
//TODO build test for EV3 Ultra Sound private async Task TestNXTUS() { NXTUltraSonicSensor ultra = new NXTUltraSonicSensor(brick, BrickPortSensor.PORT_S4); for (int i = 0; i < ultra.NumberOfModes(); i++) { int count = 0; while (count < 50) { Debug.WriteLine(string.Format("NXT US, Distance: {0}, ReadAsString: {1}, Selected mode: {2}", ultra.ReadDistance(), ultra.ReadAsString(), ultra.SelectedMode())); await Task.Delay(2000); count++; } ultra.SelectNextMode(); } }