Very confused on how to use ASYNCIO, why is my code not working? #13229
Unanswered
dumbnerd08
asked this question in
ESP32
Replies: 2 comments
-
You forgot to await on the task. There are also unnecessary function definitions. You could test this:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@dumbnerd08 Most of your code is never called. Code which is actually executed reduces to from machine import Pin, PWM
import asyncio
r = PWM(Pin(5), freq=60, duty=1023)
async def red_set_color(a):
r.duty(1023-a)
async def redblink(tim):
asyncio.create_task(red_set_color(tim))
asyncio.run(redblink(10)) The task I suggest you look at the asyncio tutorial. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
So basically, I need to blink an LED upon an interrupt. Pretend that the redblink function is run upon an IRQ interrupt. I need that function to run while the rest of my code continues running like nothing happens. I also need to be able to run multiple blink functions at the same time, with different PWMs.
Right now, when I execute the redblink function, nothing happens. No error, just nothing.
Beta Was this translation helpful? Give feedback.
All reactions