private async Task TestMultipleSensorsTouchCSSoud() { NXTTouchSensor touch = new NXTTouchSensor(BrickPortSensor.PORT_S2); EV3TouchSensor ev3Touch = new EV3TouchSensor(BrickPortSensor.PORT_S1, 20); NXTSoundSensor sound = new NXTSoundSensor(BrickPortSensor.PORT_S4); NXTColorSensor nxtlight = new NXTColorSensor(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; } }
private async Task TestEV3Color() { //brick.Stop(); //brick.SetTimeout(250); EV3ColorSensor nxtlight = new EV3ColorSensor(BrickPortSensor.PORT_S4, ColorSensorMode.Reflection); EV3TouchSensor touch = new EV3TouchSensor(BrickPortSensor.PORT_S1); //brick.Stop(); //brick.SetupSensors(); RGBColor rgb; await Task.Delay(5000); for (int i = 0; i < nxtlight.NumberOfModes(); i++) { int count = 0; while ((count < 100) && !touch.IsPressed()) { //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())); //brick.UpdateValues(); Debug.WriteLine(string.Format("EV3 Color Sensor, Raw: {0}, ReadASString: {1}", nxtlight.ReadRaw(), nxtlight.ReadAsString())); rgb = nxtlight.ReadRGBColor(); Debug.WriteLine(string.Format("Color: {0}, Red: {1}, Green: {2}, Blue: {3}", nxtlight.ReadColor(), rgb.Red, rgb.Green, rgb.Blue)); //brick.Stop(); //brick.Start(); //nxtlight.ColorMode = ColorSensorMode.Ambient; await Task.Delay(1000); //if ((touch.IsPressed()) && ev3Touch.IsPressed()) count++; //nxtlight.ColorMode = ColorSensorMode.Color; } if (nxtlight.ColorMode == ColorSensorMode.Reflection) nxtlight.ColorMode = ColorSensorMode.Color; else nxtlight.ColorMode = ColorSensorMode.Reflection; //brick.SetupSensors(); await Task.Delay(5000); } }
private async Task LunchFollowMe() { EV3TouchSensor touch = new EV3TouchSensor(BrickPortSensor.PORT_S1); NXTUltraSonicSensor ultra = new NXTUltraSonicSensor(BrickPortSensor.PORT_S3, UltraSonicMode.Centimeter); robot = new Vehicule(BrickPortMotor.PORT_B, BrickPortMotor.PORT_C); while (!touch.IsPressed()) { int valultra = ultra.Value; if ((valultra < 70) && (valultra!=0)) { Debug.WriteLine($"Taking picture, distance {valultra} cm"); await MakePicture(); } await Task.Delay(10); } Debug.Write("end of face tracking and detection"); }