Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Initialize hub and sensor
- from pybricks.pupdevices import *
- from pybricks.parameters import Port
- from pybricks.tools import wait
- ultraschallsensor = UltrasonicSensor(Port.C)
- motor1 = Motor(Port.A)
- motor2 = Motor(Port.D)
- licht = Light(Port.B)
- speed = 30
- repitions = 10
- #A: Ultraschallsensor
- #B: Lichter
- #C: First motor
- #D: Second motor
- print('start')
- while True:
- wait(100)
- if ultraschallsensor.distance() < 235:
- print(ultraschallsensor.distance())
- wait (100)
- for x in range(repitions):
- for y in range(80):
- licht.on(y+10)
- wait(10)
- for y in range(80):
- licht.on(90-y)
- wait(10)
- if x == 1:
- motor1.dc(20)
- motor2.dc(20)
- elif x == repitions-2:
- motor1.dc(-40)
- motor2.dc(-40)
- else:
- motor1.stop()
- motor2.stop()
- licht.off()
- wait(200)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement