dcexpert 发表于 2021-6-17 20:04

circuitpython 编程的提示和技巧

<p><strong>circuitpython</strong>&nbsp;编程的一些技巧和提示:</p>

<p><br />
Read an digital input as a Button</p>

<pre>
<code class="language-python">import board
from digitalio import DigitalInOut, Pull
button = DigitalInOut(board.D3) # defaults to input
button.pull = Pull.UP # turn on internal pull-up resistor
print(button.value)# False == pressed</code></pre>

<p>&nbsp;Read a Potentiometer</p>

<pre>
<code class="language-python">import board
import analogio
potknob = analogio.AnalogIn(board.A1)
position = potknob.value# ranges from 0-65535
pos = potknob.value // 256# make 0-255 range</code></pre>

<p>&nbsp;</p>

<p>**** Hidden Message *****</p>

dengfox 发表于 2024-11-9 22:48

<p>circuitpython 编程的提示和技巧,太好啊</p>
页: [1]
查看完整版本: circuitpython 编程的提示和技巧