April 2020
Intermediate to advanced
294 pages
7h 53m
English
The first step in creating a railroad blinky LED example is to import the asyncio library. In MicroPython, there is not an asyncio library exactly, but a uasyncio library. To improve portability, many developers will import uasyncio as if it were the asyncio library by importing it at the top of their application, as follows:
import uasyncio as asyncio
Next, we can define our LEDs, just like we did in all our other examples, using the following code:
LED_RED = 1LED_GREEN = 2LED_BLUE = 3LED_YELLOW = 4
If you look back at our example of writing a thread-based application, you'll recall that our task1 code looked as follows:
def task1(): while True: pyb.LED(LED_BLUE).toggle() time.sleep_ms(150) ...
Read now
Unlock full access