From fc3e54a5a4fa432e1c869fca7be76ae25621ad1e Mon Sep 17 00:00:00 2001 From: flhipp Date: Wed, 15 Feb 2023 18:48:05 +0100 Subject: [PATCH] Added if-Schleife mit Colorsensor --- iqrobot.py | 9 +++++++++ main.py | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/iqrobot.py b/iqrobot.py index 1595e5b..4a93360 100644 --- a/iqrobot.py +++ b/iqrobot.py @@ -39,8 +39,17 @@ class IQRobot: return colorIntensity + def main(self): + if self.colorSensor.get_reflected_light() > 1: + self.show('ANGRY') + else: + self.show('SAD') + colorIntensity = self.getColorIntensity() + print("Farbintensität: " + str(colorIntensity)) + + print("successfully loaded the IQ Lego teams code :)") diff --git a/main.py b/main.py index 105d83d..c1ee56d 100644 --- a/main.py +++ b/main.py @@ -82,10 +82,7 @@ hub = PrimeHub() iqRobot: iq.IQRobot = iq.IQRobot(hub, LEFT_MOTOR_PORT, RIGHT_MOTOR_PORT, COLOR_SENSOR_PORT) # Führe Funktionen aus unser Robot Klasse aus: -iqRobot.show('ANGRY') -iqRobot.driveForward_for_sec(0.5) -colorIntensity = iqRobot.getColorIntensity() -print("Farbintensität: " + str(colorIntensity)) +iqRobot.main()