【SAMR21新玩法】21. 触摸 touchio

Adafruit CircuitPython相关
MicroPython重要分支
回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

【SAMR21新玩法】21. 触摸 touchio

#1

帖子 shaoziyang »

在circuitpython中,通过touchio库可以使用触摸按键功能。例如:

代码: 全选

import time
import touchio
from microcontroller import pin

tp = touchio.TouchIn(pin.PA04)
while 1:
    time.sleep(0.5)
    tp.value
这里的触摸按键是电容式,而不是电阻式的,所以只需要一根线就可以了。触摸按键的返回是一个bool值,我们还可以读取触摸键的原始数值,或者设置触摸按键的门限,如:

代码: 全选

tp.raw_value
tp.threshold
通过修改threshold的数值,就可以调整触摸按键的灵敏度。

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章