LM35传感器驱动及说明
产品参数:
- 传感器芯片灵敏度:10mv/℃
- 供电电压:3.3V~5V
- 测量温度范围:0至100℃
Code: Select all
from microbit import *
class LM35:
def __init__(self, pin):
# vcc 主板电压
self.vcc = 3.3
self.max_Analog = 1024
self.pin = pin
def read(self):
x = self.pin.read_analog()
return x*self.vcc*100/self.max_Analog
if __name__ == "__main__":
t = LM35(pin2)
while True:
print(t.read())
sleep(1000)