Added if-Schleife mit Colorsensor

This commit is contained in:
flhipp 2023-02-15 18:48:05 +01:00
parent b8e12603c1
commit fc3e54a5a4
2 changed files with 10 additions and 4 deletions

View file

@ -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 :)")

View file

@ -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()