对于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
left side is the directory bar, the middle white background is the puzzle illustration area, and the right side is the code display area.
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
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