Not proficient in the timer code of Micropython TPYBoard V10X plug-in programming practice? ...

  对于Micropython来讲,代码编程是必不可少的一部分,但是对于DIY爱好者这个受众巨大的群体,编程就显得有点难度了,毕竟大部分人是不精通代码的。那么有没有一个更加简单的编程方式呢?今天给大家介绍如何通过拼插画图来实现常规代码编程。                                                                              

Let's implement one of the simplest timer functions.
Using micropython's timer, the red led flashes once per second.
Let's take a look at the interface of our puzzle programming: the
image description
left side is the directory bar, the middle white background is the puzzle illustration area, and the right side is the code display area.
image description
When we drag the corresponding graphics from the directory bar to the puzzle drawing area, the corresponding code will be displayed in the code display area, as shown in the figure:

1. Production process
image description

To use the timer, you first need to import the Timer library. from pyb import Timer, you can use * instead.

import pyb

from pyb import * #Import library

def test(returnValue): #function definition

LED(1).toggle()

return

t = Timer(1,freq=1,callback=test) #Define Timer: #Set the Timer number #Set the polling time #Define the frequency The larger the number, the higher the frequency

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325518387&siteId=291194637
Recommended