Ejemplo n.º 1
0
        private static void TestMultipleSensorsTouchCSSoud()
        {
            NXTTouchSensor touch    = new NXTTouchSensor(_brick, SensorPort.Port2);
            EV3TouchSensor ev3Touch = new EV3TouchSensor(_brick, SensorPort.Port1, 20);
            NXTSoundSensor sound    = new NXTSoundSensor(_brick, SensorPort.Port4);
            NXTColorSensor nxtlight = new NXTColorSensor(_brick, SensorPort.Port3);
            RGBColor       rgb;

            while (!((touch.IsPressed()) && ev3Touch.IsPressed()))
            {
                Console.WriteLine($"NXT Touch, Raw: {touch.ReadRaw()}, ReadASString: {touch.ReadAsString()}, IsPressed: {touch.IsPressed()}, NumberNodes: {touch.NumberOfModes()}, SensorName: {touch.GetSensorName()}");
                Console.WriteLine($"EV3 Touch, Raw: {ev3Touch.ReadRaw()}, ReadASString: {ev3Touch.ReadAsString()}, IsPressed: {ev3Touch.IsPressed()}, NumberNodes: {ev3Touch.NumberOfModes()}, SensorName: {ev3Touch.GetSensorName()}");
                Console.WriteLine($"NXT Sound, Raw: {sound.ReadRaw()}, ReadASString: {sound.ReadAsString()}, NumberNodes: {sound.NumberOfModes()}, SensorName: {sound.GetSensorName()}");
                Console.WriteLine($"NXT Color Sensor, Raw: {nxtlight.ReadRaw()}, ReadASString: {nxtlight.ReadAsString()}, NumberNodes: {nxtlight.NumberOfModes()}, SensorName: {nxtlight.GetSensorName()}");
                rgb = nxtlight.ReadRGBColor();
                Console.WriteLine($"Color: {nxtlight.ReadColor()}, Red: {rgb.Red}, Green: {rgb.Green}, Blue: {rgb.Blue}");
                Thread.Sleep(300);
            }
        }
Ejemplo n.º 2
0
        private async Task TestMultipleSensorsTouchCSSoud()
        {
            NXTTouchSensor touch    = new NXTTouchSensor(brick, BrickPortSensor.PORT_S2);
            EV3TouchSensor ev3Touch = new EV3TouchSensor(brick, BrickPortSensor.PORT_S1, 20);
            NXTSoundSensor sound    = new NXTSoundSensor(brick, BrickPortSensor.PORT_S4);
            NXTColorSensor nxtlight = new NXTColorSensor(brick, BrickPortSensor.PORT_S3);
            RGBColor       rgb;
            bool           bwait = true;

            while (bwait)
            {
                Debug.WriteLine(string.Format("NXT Touch, Raw: {0}, ReadASString: {1}, IsPressed: {2}, NumberNodes: {3}, SensorName: {4}", touch.ReadRaw(), touch.ReadAsString(), touch.IsPressed(), touch.NumberOfModes(), touch.GetSensorName()));
                Debug.WriteLine(string.Format("EV3 Touch, Raw: {0}, ReadASString: {1}, IsPressed: {2}, NumberNodes: {3}, SensorName: {4}", ev3Touch.ReadRaw(), ev3Touch.ReadAsString(), ev3Touch.IsPressed(), ev3Touch.NumberOfModes(), ev3Touch.GetSensorName()));
                Debug.WriteLine(string.Format("NXT Sound, Raw: {0}, ReadASString: {1}, NumberNodes: {2}, SensorName: {3}", sound.ReadRaw(), sound.ReadAsString(), sound.NumberOfModes(), sound.GetSensorName()));
                Debug.WriteLine(string.Format("NXT Color Sensor, Raw: {0}, ReadASString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              nxtlight.ReadRaw(), nxtlight.ReadAsString(), nxtlight.NumberOfModes(), nxtlight.GetSensorName()));
                rgb = nxtlight.ReadRGBColor();
                Debug.WriteLine(string.Format("Color: {0}, Red: {1}, Green: {2}, Blue: {3}",
                                              nxtlight.ReadColor(), rgb.Red, rgb.Green, rgb.Blue));
                //                Debug.WriteLine(string.Format("raw {0}", nxtlight.ReadTest()));
                await Task.Delay(300);

                if ((touch.IsPressed()) && ev3Touch.IsPressed())
                {
                    bwait = false;
                }
            }
        }