Python一次只从GPIO追加一个数据
所以我刚开始使用python,从一个连接到树莓圆周率的称重传感器中提取读数。代码如下:Python一次只从GPIO追加一个数据,python,list,raspberry-pi,append,Python,List,Raspberry Pi,Append,所以我刚开始使用python,从一个连接到树莓圆周率的称重传感器中提取读数。代码如下: hx = HX711(5, 6) hx.set_reading_format("LSB", "MSB") hx.set_reference_unit(26.978) hx.reset() hx.tare() while True: for i in range (15): val = int(hx.get_weight(5)) newval = abs(round(
hx = HX711(5, 6)
hx.set_reading_format("LSB", "MSB")
hx.set_reference_unit(26.978)
hx.reset()
hx.tare()
while True:
for i in range (15):
val = int(hx.get_weight(5))
newval = abs(round((float(val/1000)),1))
X = []
X.append (newval)
print ([X])
hx.power_down()
hx.power_up()
我想我会在这个时间范围内得到一份阅读清单,也许是4?但我总是得到一个。数据肯定会频繁地进入列表,但我的列表总是只有一个数据
我肯定我做错了什么,请帮我大忙。我注意到的两件事都是错的:
hx = HX711(5, 6)
hx.set_reading_format("LSB", "MSB")
hx.set_reference_unit(26.978)
hx.reset()
hx.tare()
while True:
X = []
for i in range (15):
val = int(hx.get_weight(5))
newval = abs(round((float(val/1000)),1))
X.append (newval)
hx.power_down()
hx.power_up()
print ([X])
将显示一组包含15个值的列表