Compare commits

..

6 commits

Author SHA1 Message Date
060a72c2a7 Merge pull request 'Abstandssensor' (#9) from laptop_3 into main
Reviewed-on: #9
Reviewed-by: Lars Haferkamp <lahaferk@linuxmuster.lan>
2023-11-22 18:01:14 +00:00
Laptop 3
dc59501781 . 2023-11-22 19:00:15 +01:00
Laptop 3
01b4c1ebc6 Docs 2023-11-22 18:49:27 +01:00
Laptop 3
4a0671105b Debug entfernt 2023-11-22 18:48:30 +01:00
Laptop 3
83c580e54f Port gefixt 2023-11-22 18:47:07 +01:00
Laptop 3
6de4a7a70b Abstandssensor 2023-11-22 18:43:25 +01:00

View file

@ -2,7 +2,7 @@
import math import math
from spike import PrimeHub, Motor, MotorPair, ColorSensor, MotionSensor from spike import PrimeHub, Motor, MotorPair, ColorSensor, MotionSensor, DistanceSensor
from spike.control import wait_for_seconds from spike.control import wait_for_seconds
HELLO = "HELLO IQ" HELLO = "HELLO IQ"
@ -40,6 +40,8 @@ class IQRobot:
self.bewegungsSensor: MotionSensor = MotionSensor() self.bewegungsSensor: MotionSensor = MotionSensor()
self.abstandsSensor: DistanceSensor = DistanceSensor("D")
def show(self, image: str): def show(self, image: str):
''' '''
@ -150,6 +152,15 @@ class IQRobot:
self.bothFrontMotors.move(rotations, unit='rotations',speed=20) self.bothFrontMotors.move(rotations, unit='rotations',speed=20)
def fahre_bis_abstand(self, abstand: int, speed=30, geregelt=True):
self.antrieb.start_at_power(speed)
abstand_gerade = self.abstandsSensor.get_distance_cm()
while abstand_gerade > abstand:
abstand_gerade = self.abstandsSensor.get_distance_cm()
print(str(abstand_gerade))
self.antrieb.stop()
print("successfully loaded the IQ Lego teams code :)") print("successfully loaded the IQ Lego teams code :)")
@ -159,3 +170,4 @@ print("successfully loaded the IQ Lego teams code :)")