烽火社区

标题: MicroPython的旋转编码器库 [打印本页]

作者: ferrariyy    时间: 2016-9-4 09:21 PM
标题: MicroPython的旋转编码器库
国外网友写的旋转编码器库

使用方法:

  1. from machine import sleep_ms
  2. from encoder import Encoder  # or from pyb_encoder import Encoder

  3. e = Encoder('X11', 'X12')  # optional: add pin_mode=Pin.PULL_UP
  4. lastval = e.value

  5. while True:
  6.     val = e.value
  7.     if lastval != val:
  8.         lastpos = val
  9.         print(val)
  10.     sleep_ms(100)
复制代码


https://github.com/SpotlightKid/micropython-stm-lib/tree/master/encoder






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