Added if-Schleife mit Colorsensor
This commit is contained in:
parent
b8e12603c1
commit
fc3e54a5a4
2 changed files with 10 additions and 4 deletions
|
@ -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 :)")
|
||||
|
||||
|
|
5
main.py
5
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()
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue