Replies: 6 comments
-
please help me fix the code |
Beta Was this translation helpful? Give feedback.
-
UG = 0
async def motor_a():
a = 1
while a == 1:
enc_A = right_motor.angle()
err = UG - enc_A
U = err * 1
Motor_Left.dc(U)
await wait(5) |
Beta Was this translation helpful? Give feedback.
-
Yes, it's a brand new feature. Once it is fully tested and documented we'll move it over to the stable version. Thanks for giving it a try! We'd love your feedback if it isn't working as expected. Here is an example: from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Direction, Stop, Color
from pybricks.robotics import DriveBase
from pybricks.tools import wait, multitask, run_task
# Initialize devices as usual. You can do this on any hub.
hub = PrimeHub()
left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.B)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112)
# Task to drive in a square.
async def square():
for side in range(4):
# Drive forward and then turn.
await drive_base.straight(200)
await drive_base.turn(90)
# Task to blink.
async def blink():
for i in range(10):
hub.light.on(Color.RED)
await wait(500)
hub.light.on(Color.GREEN)
await wait(500)
# Hello world task.
async def hello(name):
print("Hello!")
await wait(2000)
print(name)
# This is the main program
async def main():
print("Running multiple tasks at once!")
await multitask(square(), blink(), hello("Pybricks"))
print("You can also just run one task.")
await hello("World!")
# Run the main program.
run_task(main()) |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot |
Beta Was this translation helpful? Give feedback.
-
Hello with this code i get this error: |
Beta Was this translation helpful? Give feedback.
-
Hi, Which version are you using? I tried this program at beta.pybricks.com:
No problem, here. |
Beta Was this translation helpful? Give feedback.
-
multitask is only available in this version https://beta.pybricks.com/ ?
Doesn't it work in the standard version?
Beta Was this translation helpful? Give feedback.
All reactions