Replies: 4 comments
-
Check out: |
Beta Was this translation helpful? Give feedback.
-
Using def forward(ms):
asyncio.create_task(go_forward(ms))
async def go_foward(ms):
motor.start() # Start it running
await asyncio.sleep_ms(ms)
motor.stop() The great advantage being that |
Beta Was this translation helpful? Give feedback.
-
You can use the asyncio library to manage time-based tasks asynchronously, allowing you to control the motor without blocking other tasks. You can also use Millis-Based Non-Blocking Logic like this: def forward(ms):
forward(500) |
Beta Was this translation helpful? Give feedback.
-
Thanks for your suggestions.
|
Beta Was this translation helpful? Give feedback.
-
Hi,
I am looking to control a motor (with an ESP32) for a short set duration, 500ms for example. I thought about this code but I think the motor stops for the time.sleep_ms, then resumes and so on. Which is not great
I looked at the Timer function but the documentation states that this function uses an interrupt which by definition must be very short.
Maybe I should turn to asyncio?
Would you have a better idea to submit to me
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions