开箱体验 【microPython学习板试用体验】+ 串口点灯测评

发布时间: 2018-11-14
阅读: 809
0
产品概况
本帖最后由 何口可口可 于 2018-11-15 23:04 编辑

pyboard V2已经到了很久了因为项目忙都没时间捣鼓,今天发短信来才注意到。pyboard V2选用的是STM32F4主控芯片。首次插入电脑,我的电脑会增加一个新的设备。
然后打开SecureCRT选择串口和波特率115200,就能出来提示
Traceback (most recent call last):
  File "main.py", line 1, in <module>
NameError: name '' is not defined
MicroPython v1.9.4-114-g309fe39d on 2018-06-04; PYBv1.0 with STM32F405RG
Type "help()" for more information.


这是时候可以根据提示输入help();
>>> help()
Welcome to MicroPython!

For online help please visit

Quick overview of commands for the board:
  pyb.info()    -- print some general information
  pyb.delay(n)  -- wait for n milliseconds
  pyb.millis()  -- get number of milliseconds since hard reset
  pyb.Switch()  -- create a switch object
                   Switch methods: (), callback(f)
  pyb.LED(n)    -- create an LED object for LED n (n=1,2,3,4)
                   LED methods: on(), off(), toggle(), intensity(<n>)
  pyb.Pin(pin)  -- get a pin, eg pyb.Pin('X1')
  pyb.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
                   Pin methods: init(..), value([v]), high(), low()
  pyb.ExtInt(pin, m, p, callback) -- create an external interrupt object
  pyb.ADC(pin)  -- make an analog object from a pin
                   ADC methods: read(), read_timed(buf, freq)
  pyb.DAC(port) -- make a DAC object
                   DAC methods: triangle(freq), write(n), write_timed(buf, freq)
  pyb.RTC()     -- make an RTC object; methods: datetime([val])
  pyb.rng()     -- get a 30-bit hardware random number
  pyb.Servo(n)  -- create Servo object for servo n (n=1,2,3,4)
                   Servo methods: calibration(..), angle([x, [t]]), speed([x, [t]])
  pyb.Accel()   -- create an Accelerometer object
                   Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()

Pins are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name
Pin IO modes are: pyb.Pin.IN, pyb.Pin.OUT_PP, pyb.Pin.OUT_OD
Pin pull modes are: pyb.Pin.PULL_NONE, pyb.Pin.PULL_UP, pyb.Pin.PULL_DOWN
Additional serial bus objects: pyb.I2C(n), pyb.SPI(n), pyb.UART(n)

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-C        -- interrupt a running program
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
会有一些命题的提示,这些和LINUX开发板有些类似。
>>> pyb.
__class__       __name__        SD              DAC
RTC             ADC             ADCAll          Accel
CAN             ExtInt          Flash           I2C
LCD             LED             Pin             SDCard
SPI             Servo           Switch          Timer
UART            USB_HID         USB_VCP         bootloader
delay           dht_readinto    disable_irq     elapsed_micros
elapsed_millis  enable_irq      fault_debug     freq
hard_reset      have_cdc        hid             hid_keyboard
hid_mouse       info            main            micros
millis          mount           pwm             repl_info
repl_uart       rng             servo           standby
stop            sync            udelay          unique_id
usb_mode        wfi

这是一些pyboard V2支持的一些接口。
这时我想点亮LED灯。过程就是这样了
>>> from pyb import LED
>>> led = LED(1)
>>> led.
__class__       intensity       off             on
toggle
>>> led.toggle()
>>> led.on()
>>> led.off()
>>> led = LED(1)
>>> led.
__class__       intensity       off             on
toggle
>>> led.toggle()
>>> led.on()

这时,红色LED灯就点亮了,OFF就熄灭。操作很简单的只要有点python知识都可以操作的。
最后想说pyboard V2这块板子很好使用,简单入门。尤其是对于那些没有什么硬件基础,或者想学编程(python)的人来说还是很方便的只要一根USB线连接就可以了,相对于ST出的CUBEMX生成软件,我觉得pyboard V2更好玩。因为时间有限这两个月公司变动比较大,太忙了不然肯定会好好玩一玩pyboard V2这块板子。


原创作品,未经权利人授权禁止转载。详情见转载须知

microPython学习板 pyboard V2
  • microPython学习板 pyboard V2
  • ¥68.00
立即申请
评论(0)

登录后可评论,请 登录注册

X
提交成功 ! 谢谢您的支持
返回