在这里对 python 来说相当新,并试图将 time.sleep 函数分离出来以进行多次阅读。
while True:
#read from a analog sensor on input 1
d= grovepi.analogRead(1)
#read from an analog sensor on input 2
a= grovepi.analogRead(2)
#read from an digital sensor on input 3
(t,h)=grovepi.dht(3,0)
#output the data
#print (datetime,time)
print('Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
print ("Noise:",d,"dB")
print ("Light:",a,"lux")
print ("Temperature:",t,"C")
print ("Humidity:",h,"rH")
grovelcd.setText("T:" + str(t) + " H:" + str(h) + " N:" + str(d)+ " L:" + str(a))
time.sleep(5)
我想要的是读数以不同的频率打印,但仍同时运行。
例如
print ("Noise:",d,"dB")
time.sleep(3)
和
print ("Light:",a,"lux")
time.sleep(5)
我知道这可能是一个简单的语法问题,但我还没有找到一个简单的解决方案。
非常感谢