这个构造函数不带参数 lcd [英] This constructor takes no arguments lcd

查看:71
本文介绍了这个构造函数不带参数 lcd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我试图显示湿度传感器数据的代码到我的液晶显示器...

This is the code that I am trying to display humidity sensor data to my lcd...

当我运行这个程序时,

回溯(最近一次调用最后一次):文件lcd.py",第 7 行lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23]) TypeErrir:这个构造函数不接受论据

Traceback(most recent call last): File "lcd.py", line 7 in lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23]) TypeErrir: this constructor takes no arguments

import sys
import Adafruit_DHT

from RPLCD import CharLCD

lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23])


while True:
    humidity, temperature = Adafruit_DHT.read_retry(11, 4)

    lcd.cursor_pos = (0, 0)
    lcd.write_string("Temp: %d C" % temperature)
    lcd.cursor_pos = (1, 0)
    lcd.write_string("Humidity: %d %%" % humidity)

我已经把所有的别针都放对了,但我不确定我做错了什么.

I have put all the pins right but i am not sure what i did wrong.

推荐答案

不确定您使用的是哪个版本的 RPLCD,但在当前稳定版本中它说使用 RPLCD.CharLCD 直接被弃用.尝试将导入语句切换为

Not sure which version of RPLCD you are using, but in the current stable version it says that using RPLCD.CharLCD directly is deprecated. Try switching the import statement to

from RPLCD.gpio import CharLCD

更多文档在这里

这篇关于这个构造函数不带参数 lcd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆