-
This was also posted on Stack Overflow, it has been 2 days and I have no answers. I am wondering if somebody here can help me. I have a Lego Mindstorms EV3 running MicroPython. #!/usr/bin/env pybricks-micropython
from pybricks.robotics import DriveBase, Stop
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor, InfraredSensor
from pybricks.parameters import Port, Direction
from pybricks.tools import wait
# Initialize the EV3 Brick.
ev3 = EV3Brick()
# Initialize Wheels
RightWheel = Motor(Port.B)
LeftWheel = Motor(Port.C)
Robot = DriveBase(LeftWheel, RightWheel, 275.2, 165)
Robot.settings(straight_speed=1000)
# Initialize Motors and Sensors
blade_motor = Motor(Port.D, positive_direction=Direction.CLOCKWISE, gears=None)
infrared_sensor = InfraredSensor(Port.S1)
pressed = infrared_sensor.keypad()
# Play a sound to tell us when we are ready to start moving
ev3.speaker.beep()
LeftWheel.run(1000) If I replace I have no idea why this would happen, I have looked everywhere, and it seems to be just me that is having this issue. |
Beta Was this translation helpful? Give feedback.
Answered by
dlech
Nov 20, 2023
Replies: 1 comment 2 replies
-
Has to be in while loop |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, the best place to ask for help with Pybricks is https://github.com/orgs/pybricks/discussions.
Technically, it doesn't have to be in a while loop. You just need something that makes sure that the program does not reach the end. Motors are stopped when the program reaches the end.
run_time()
works because it blocks program execution for some amount of time. Butrun()
does not block program execution, so the program ends immediately and stops the motors.