diff --git a/Code/C_Code/20.1.1_I2CLCD1602/I2CLCD1602.c b/Code/C_Code/20.1.1_I2CLCD1602/I2CLCD1602.c index cbab64b..ebbc582 100644 --- a/Code/C_Code/20.1.1_I2CLCD1602/I2CLCD1602.c +++ b/Code/C_Code/20.1.1_I2CLCD1602/I2CLCD1602.c @@ -2,7 +2,7 @@ * Filename : I2CLCD1602.c * Description : Use the LCD display data * Author : freenove -* modification: 2016/06/25 +* modification: 2017/04/18 **********************************************************************/ #include #include @@ -11,7 +11,8 @@ #include #include -#define pcf8574_address 0x27 // default I2C address of Pcf8574 +//#define pcf8574_address 0x27 // default I2C address of Pcf8574 +#define pcf8574_address 0x3F // default I2C address of Pcf8574A #define BASE 64 // BASE is not less than 64 //////// Define the output pins of the PCF8574, which are directly connected to the LCD1602 pin. #define RS BASE+0 diff --git a/Code/Python_Code/20.1.1_I2CLCD1602/I2CLCD1602.py b/Code/Python_Code/20.1.1_I2CLCD1602/I2CLCD1602.py index e9e78e0..eb48bda 100644 --- a/Code/Python_Code/20.1.1_I2CLCD1602/I2CLCD1602.py +++ b/Code/Python_Code/20.1.1_I2CLCD1602/I2CLCD1602.py @@ -3,7 +3,7 @@ # Filename : I2CLCD1602.py # Description : Use the LCD display data # Author : freenove -# modification: 2016/06/26 +# modification: 2017/04/18 ######################################################################## from PCF8574 import PCF8574_GPIO from Adafruit_LCD1602 import Adafruit_CharLCD @@ -33,9 +33,17 @@ def loop(): def destroy(): lcd.clear() -address = 0x27 # I2C address of the PCF8574 chip. +PCF8574_address = 0x27 # I2C address of the PCF8574 chip. +PCF8574A_address = 0x3F # I2C address of the PCF8574A chip. # Create PCF8574 GPIO adapter. -mcp = PCF8574_GPIO(address) +try: + mcp = PCF8574_GPIO(PCF8574_address) +except: + try: + mcp = PCF8574_GPIO(PCF8574A_address) + except: + print 'I2C Address Error !' + exit(1) # Create LCD, passing in MCP GPIO adapter. lcd = Adafruit_CharLCD(pin_rs=0, pin_e=2, pins_db=[4,5,6,7], GPIO=mcp) diff --git a/Code/Python_Code/20.1.1_I2CLCD1602/PCF8574.py b/Code/Python_Code/20.1.1_I2CLCD1602/PCF8574.py index 9206f4a..50fb5ce 100644 --- a/Code/Python_Code/20.1.1_I2CLCD1602/PCF8574.py +++ b/Code/Python_Code/20.1.1_I2CLCD1602/PCF8574.py @@ -2,7 +2,7 @@ # Filename : PCF8574.py # Description : PCF8574 as Raspberry GPIO # Author : freenove -# modification: 2016/06/26 +# modification: 2017/04/18 ######################################################################## import smbus import time @@ -15,6 +15,7 @@ class PCF8574_I2C(object): self.bus = smbus.SMBus(1) self.address = address self.currentValue = 0 + self.writeByte(0) #I2C test. def readByte(self):#Read PCF8574 all port of the data #value = self.bus.read_byte(self.address) diff --git a/Tutorial.pdf b/Tutorial.pdf index cd4581c..4d37c71 100644 Binary files a/Tutorial.pdf and b/Tutorial.pdf differ