static void DisplayActivateSentrybot(double lowerTempThresholdValue, Finch myfinch, double lowerLightThreshold) { double ambientTemp; double ambientLight; ambientTemp = myfinch.getTemperature(); //ambientLight = myfinch.getRightLightSensor() + myfinch.getLeftLightSensor(); ambientLight = myfinch.getLightSensors().Average(); DisplayHeader("Activate Sentry Bot"); Console.WriteLine($"The ambient temperature is {ambientTemp}"); Console.WriteLine($"The lower Temperature Threshold is {lowerTempThresholdValue}"); while (!TemperatureBelowThresholdValue(lowerTempThresholdValue, myfinch) && !LightAboveThresholdValue(lowerLightThreshold, myfinch)) { Console.WriteLine($"light threshold{lowerLightThreshold}, light {ambientLight}, temp threshold {lowerTempThresholdValue}, temp {ambientTemp}"); TemperatureNominalIndicator(myfinch); } //if (TemperatureBelowThresholdValue(lowerTempThresholdValue, myfinch) && LightAboveThresholdValue(lowerLightThreshold, myfinch)) //{ myfinch.noteOn(250); myfinch.setLED(255, 0, 0); myfinch.wait(3000); myfinch.noteOff(); myfinch.setLED(0, 0, 0); //} DisplayContinuePrompt(); }
private void SetLightLevel(object sender, EventArgs e) { int[] lightlevels = Ayew.getLightSensors(); double lightLevel = lightlevels.Average(); txtBox_LightLevel.Text = lightLevel.ToString(); }
/// <summary> /// Get temp data from finch. /// </summary> static (string temperatureData, string lightData) DisplayGetFinchData(Finch robot) { string temperatureData = Convert.ToString(robot.getTemperature()); string lightData = Convert.ToString(robot.getLightSensors()); DisplayContinuePrompt(); return(temperatureData, lightData); }
private void SetLightLevel(object sender, EventArgs e) { // //program the finch to measure light levels // int[] lightlevels = Ayew.getLightSensors(); double lightLevel = lightlevels.Average(); txtBox_LightLevel.Text = lightLevel.ToString(); }
static double CalculateAmbientLight(Finch myFinch) { double ambientLight; int[] ambientLightArray = new int[1]; ambientLightArray = myFinch.getLightSensors(); ambientLight = ambientLightArray.Average(); return(ambientLight); }
static bool LightAboveThresholdValue(double lowerLightThreshold, Finch myfinch) { if (myfinch.getLightSensors().Average() > lowerLightThreshold) { return(true); } else { return(false); } }
static int LightAlarmCurrentSensorValue(Finch finchRobot, string sensorsToMonitor) { int currentLightSensorValue = 0; switch (sensorsToMonitor) { case "left": currentLightSensorValue = finchRobot.getLeftLightSensor(); break; case "right": currentLightSensorValue = finchRobot.getRightLightSensor(); break; case "both": currentLightSensorValue = (finchRobot.getLeftLightSensor() + finchRobot.getRightLightSensor()) / 2; currentLightSensorValue = (int)(finchRobot.getLightSensors().Average()); break; } return(currentLightSensorValue); }
/// <summary> /// This is just for getting light data in an array /// </summary> /// <param name="Reznor"></param> /// <returns> The reading of both amounts of light!</returns> public static int[] GetLightData(Finch Reznor) { DisplayHeader("Reznor will see how much light is nearby!"); DisplayContinuePromt(); int[] lightSensor = Reznor.getLightSensors(); for (int index = 0; index < lightSensor.Length; index++) { Console.WriteLine($"\tHere we go! {lightSensor[index]}"); } DisplayContinuePromt(); return(lightSensor); //int leftLight; //leftLight = Reznor.getLeftLightSensor(); // Console.WriteLine($"SHOW ME LIGHT {leftLight}"); // Console.ReadKey(); }