Code: Alles auswählen
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile
import sys
# This program requires LEGO EV3 Micropython v2.0 or higher.
# Click "Open User Guide" on the EV3 extension tab for more information.
# Create your objects here.
ev3 = EV3Brick()
timer = StopWatch()
leg_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
trunk_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
neck_motor = Motor(Port.D)
while True:
while Button.CENTER in ev3.buttons.pressed():
leg_motor.run_target(1000, 3680)
neck_motor.run_target(500, 580)
trunk_motor.run_target(-809, 1200)
ev3.speaker.play_file(SoundFile.ELEPHANT_CALL)
trunk_motor.run_target(500, 0)
neck_motor.run_target(500, -0)
wait(5000)
leg_motor.run_target(1009, -0)
while Button.CENTER not in ev3.buttons.pressed():
leg_motor.run_target(1009, 0)
trunk_motor.run_target(500, 0)
neck_motor.run_target(500, 0)
timer.reset()
if Button.DOWN in ev3.buttons.pressed():
sys.exit()