time.sleep(0.2) lcd_addr = -1 if ablib.existI2Cdevice(0, 0x27): print "PCF8474T" lcd_addr = 0x27 if ablib.existI2Cdevice(0, 0x3F): print "PCF8474AT" lcd_addr = 0x3F if lcd_addr == -1: continue try: lcd = ablib.Daisy24(0, lcd_addr) if lcd_addr == 0x27: lcd.putstring("Daisy-24 (T)") if lcd_addr == 0x3F: lcd.putstring("Daisy-24 (AT)") if lcd.pressed(0): lcd.setcurpos(0, 1) lcd.putstring("Key 0 pressed") lcd.backlighton() time.sleep(1) lcd.backlightoff() if lcd.pressed(1): lcd.setcurpos(0, 1)
import ablib import time #Daisy-24 I/O expander chip address. Use: #0x27 for PCF8474 T #0x3F for PCF8474 AT LCD_ADDRESS = 0x27 while True: try: lcd = ablib.Daisy24(0, LCD_ADDRESS) lcd.putstring("Test Daisy-24") except: continue if lcd.pressed(0): lcd.setcurpos(0, 1) lcd.putstring("Key 0 pressed") lcd.backlighton() time.sleep(1) lcd.backlightoff() if lcd.pressed(1): lcd.setcurpos(0, 1) lcd.putstring("Key 1 pressed") lcd.backlighton() time.sleep(1) lcd.backlightoff() if lcd.pressed(2):
import ablib import time #Check for Daisy-24 address if ablib.existI2Cdevice(0, 0x27): i2c_address = 0x27 else: i2c_address = 0x3F lcd = ablib.Daisy24(0, i2c_address) lcd.backlighton() lcd.putstring("Hello World !") while True: i = 0 while i < 10: i += 1 lcd.setcontrast(i) time.sleep(0.1) while i > 0: i -= 1 lcd.setcontrast(i) time.sleep(0.1)
import ablib import time lcd = ablib.Daisy24(0) lcd.backlighton() lcd.putstring("Hello World !") while True: i=0 while i<10: i+=1 lcd.setcontrast(i) time.sleep(0.1) while i>0: i-=1 lcd.setcontrast(i) time.sleep(0.1)