代码拉取完成,页面将自动刷新
import time
import ds18b20
from ds18b20 import ds
time.sleep(1)
sensor=ds(2,'c',12) #creates sensor object set to default pin 2, units in Celcius, resolution 12 bit
#sensor.addr, sensor.pin, sensor.unit, and sensor.res values are now available
#you can change the object parameters by the following:
#pin number - sensor.pin=[number]
#unit - sensor.unit=['c'|'f']
#resolution - sensor.res=[9|10|11|12]
while True:
temp=ds18b20.read(sensor) # a time.sleep is builtin to the function to allow time to take the reading
#the builtin time.sleep is currently set to 1 second for all resolutions but will eventually
#take less time for the lower resolutions once it has been added to the library
print (temp)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。