美文网首页
Micropython | Pyboard 小车

Micropython | Pyboard 小车

作者: T_K_233 | 来源:发表于2018-10-02 07:07 被阅读0次
pyboard 参考图

蓝牙收发

from pyb import UART

baudrate = 38400
uart = UART(1, baudrate)
串口对应GPIO
  • UART(4) is on XA: (TX, RX) = (X1, X2) = (PA0, PA1)
  • UART(1) is on XB: (TX, RX) = (X9, X10) = (PB6, PB7)
  • UART(6) is on YA: (TX, RX) = (Y1, Y2) = (PC6, PC7)
  • UART(3) is on YB: (TX, RX) = (Y9, Y10) = (PB10, PB11)
  • UART(2) is on: (TX, RX) = (X3, X4) = (PA2, PA3)
uart.init(baudrate, bits=8, parity=None, stop=1, *, timeout=1000, flow=None, timeout_char=0, read_buf_len=64)
  • baudrate:波特率
  • bits:数据位,7/8/9
  • parity:校验,None, 0 (even) or 1 (odd)
  • stop:停止位,1/2
  • flow:流控,可以是 None, UART.RTS, UART.CTS or UART.RTS | UART.CTS
  • timeout:读取一个字节的超时时间(ms)
  • timeout_char:两个字节之间超时时间
uart.write()
uart.read([num_of_bytes])

PWM

motor = Timer(5, freq=2000).channel(3, Timer.PWM, pin=Pin.board.X3)

Timer(nclock, freq)
Timer.channel(channel, mode, pin)
这里的参数参考第一张图

motor.pulse_width_percent(50)

从 0 到 50

相关文章

网友评论

      本文标题:Micropython | Pyboard 小车

      本文链接:https://www.haomeiwen.com/subject/jgyooftx.html