PYB Nano如何实现用定时器控制跑马灯
发表于 : 2019年 11月 17日 00:23
学习《MicroPython入门指南》一书4.7章中,用定时器控制跑马灯程序输进去报以下错误,
>>> from pyb import Timer
>>> n = 0
>>> def f(t):
... global n
... n = (n+1)%4
... pyb.LED(n).toggle()
...
...
... tm = Timer(1,freq=20,callback=f)
...
Traceback (most recent call last):
File "<stdin>", line 7
SyntaxError: invalid syntax
请问是因为和PYB V10接口不一致的原因还是什么原因,另外问一下,PYB Nano V2 还需要升级固件吗?
谢谢!
>>> from pyb import Timer
>>> n = 0
>>> def f(t):
... global n
... n = (n+1)%4
... pyb.LED(n).toggle()
...
...
... tm = Timer(1,freq=20,callback=f)
...
Traceback (most recent call last):
File "<stdin>", line 7
SyntaxError: invalid syntax
请问是因为和PYB V10接口不一致的原因还是什么原因,另外问一下,PYB Nano V2 还需要升级固件吗?
谢谢!