schreibe Lego mit Segmenten
This commit is contained in:
parent
8e7836dac5
commit
e29586681a
1 changed files with 34 additions and 14 deletions
48
iqrobot.py
48
iqrobot.py
|
@ -50,8 +50,36 @@ class IQRobot:
|
|||
self.movementMotors.stop()
|
||||
|
||||
|
||||
def buchstabe_zu_segmenten(self, buchstabe):
|
||||
# Segmente um Buchstaben zu schreiben
|
||||
# 5_
|
||||
# 6 |__|4
|
||||
# 1 |7_|3
|
||||
# 2
|
||||
#
|
||||
buchstabe_zu_segmenten = {"L": [1,1,0,0,0,1,0], "E": [1,1,0,0,1,1,1], "G": [1,1,1,0,1,1,0], "O": [1,1,1,1,1,1,0]}
|
||||
return buchstabe_zu_segmenten[buchstabe]
|
||||
|
||||
|
||||
def bewege_stift(self, richtung):
|
||||
self.frontMotorRight.run_for_rotations(richtung*0.4)
|
||||
|
||||
def schreibe_buchstabe(self, buchstabe):
|
||||
print(f"Schreibe {buchstabe}")
|
||||
segmente = self.buchstabe_zu_segmenten(buchstabe)
|
||||
grad_drehung=90
|
||||
self.movementMotors.move(2)
|
||||
self.drehe(grad_drehung)
|
||||
for segment, segment_nummer in enumerate(segmente):
|
||||
if segment==1:
|
||||
self.bewege_stift(-1)
|
||||
self.movementMotors.move(5)
|
||||
if segment==1:
|
||||
self.bewege_stift(1)
|
||||
if segment_nummer+1 != 3:
|
||||
self.drehe(grad_drehung)
|
||||
|
||||
|
||||
def schreibeL(self, schreibe=True, zurueck=False):
|
||||
if zurueck:
|
||||
step = 5
|
||||
|
@ -94,22 +122,14 @@ class IQRobot:
|
|||
# und fahre 2cm fohrwärts
|
||||
#stift hoch
|
||||
|
||||
def schreibeE(self):
|
||||
print("Schreibe E")
|
||||
|
||||
def schreibeG(self):
|
||||
print("Schreibe G")
|
||||
|
||||
|
||||
def schreibeO(self):
|
||||
print("Schreibe O")
|
||||
|
||||
def schreibeLego(self):
|
||||
self.schreibeL()
|
||||
self.schreibeL(schreibe=False, zurueck=True)
|
||||
self.schreibeE()
|
||||
self.schreibeG()
|
||||
self.schreibeO()
|
||||
#self.schreibeL()
|
||||
#self.schreibeL(schreibe=False, zurueck=True)
|
||||
self.schreibe_buchstabe("L")
|
||||
self.schreibe_buchstabe("E")
|
||||
self.schreibe_buchstabe("G")
|
||||
self.schreibe_buchstabe("O")
|
||||
|
||||
print("successfully loaded the IQ Lego teams code :)")
|
||||
|
||||
|
|
Loading…
Reference in a new issue