adafruit ライブラリは、RPI GPIO または MCP230XX i2C gpio エクスパンダ上で Python を使用して LCD 制御を提供します。PCF8574も同じ発想でいきたいです。それはすべてこれらのことについてです: http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html
LCD に使用する Adafruit ライブラリは次のとおりです: https://github.com/adafruit/Adafruit_Python_CharLCD
Adafruit_GPIO には、PCF8574 i2C gpio エクスパンダ用のライブラリも含まれています。 https://github.com/adafruit/Adafruit_Python_GPIO
例では、MCP230XX のみを使用しており、PCF8574 は使用していません。
何時間も試してみましたが、adafruit コードで正しく動作しません。
動作するコードを見つけましたが、より良いメンテナンスとサポートのために、代わりに adafruit コードを使用したいことに注意してください。作業コードはこれです: https://github.com/goshkis/rpi/blob/master/lcddriver.py
これが私の現在のコードです:
#!/usr/bin/env python
import time
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.PCF8574 as PCF
# Define PCF pins connected to the LCD.
PCF8574T_addr = 0x27
lcd_rs = 0
lcd_rw = 1
lcd_en = 2
lcd_d4 = 4
lcd_d5 = 5
lcd_d6 = 6
lcd_d7 = 7
lcd_backlight = 3
# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows = 2
# Initialize i2C device using its I2C address.
gpio = PCF.PCF8574(PCF8574T_addr, busnum=1)
# Initialize the LCD
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
lcd_columns, lcd_rows, lcd_backlight, gpio=gpio)
# Clear display and show greeting, pause 1 sec
lcd.clear()
lcd.set_backlight(True)
lcd.message("Gartenwasser startet...")
time.sleep(1)
私が犯したエラーを見つけることができますか?