烽火社区

标题: MicroPython点亮LED [打印本页]

作者: 一醉千年    时间: 2016-5-26 02:21 PM
标题: MicroPython点亮LED
[attach]30811[/attach]



在windows 下把MicroPython开发板通过USB 连接到电脑上。
windows会识别一个U盘。如下所示:

[attach]30812[/attach]

打开这个PYBFLASH的U盘,可以看到如下的文件:
[attach]30813[/attach]

boot.py – this script is executed when the pyboard boots up. It setsup various configuration options for the pyboard. 开发板上电的时候第一次执行的文件。类似于arduino的setup()
main.py – this is the main script that will contain your Python program.It is executed after boot.py.  在boot.py之后执行的程序,用户的代码可以写在这里面。
README.txt – this contains some very basic information about gettingstarted with the pyboard.
pybcdc.inf – this is a Windows driver file to configure the serial USBdevice. More about this in the next tutorial.


修改 main.py 文件如下:
  1. <font size="5"># main.py -- put your code here!
  2. from pyb import LED

  3. led = LED(1) # red led
  4. led.toggle()
  5. led.on()</font>
复制代码
上电,即可看到 红色led点亮。

编程变得如此的简单。。。



作者: 玻璃茶    时间: 2016-5-26 02:41 PM
点赞
作者: mcdevices3    时间: 2016-5-26 06:11 PM
gtrjolin1986 发表于 2016-5-26 14:41
点赞

一起玩,,,,




欢迎光临 烽火社区 (http://bbs.cnecport.com/) Powered by Discuz! X3.2