LCD 1602 - Library
Re: LCD 1602 - Library
There are two versions of this device - the difference is the controller IC. If you have the PCF8574T. the default I2C bus address is 0x27. If you have the PCF8574AT the default I2C bus address is 0x3F. An i2c.scan() should reveal which address to use
-
- Posts: 51
- Joined: Wed May 08, 2019 10:54 am
Re: LCD 1602 - Library
Hi Robert, i got [39] as per below screenshotRoberthh wrote: ↑Sun Jun 09, 2019 6:03 pmWhat do you get with
Code: Select all
from machine import I2C i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000) print(i2c.scan())
Re: LCD 1602 - Library
The instantiation of lcd should be:
lcd=I2cLcd(i2c, 0x27, 2, 16)
or
lcd=I2cLcd(i2c, 39, 2, 16)
You screen dump shows 0*27, which is 0
lcd=I2cLcd(i2c, 0x27, 2, 16)
or
lcd=I2cLcd(i2c, 39, 2, 16)
You screen dump shows 0*27, which is 0
-
- Posts: 51
- Joined: Wed May 08, 2019 10:54 am
-
- Posts: 51
- Joined: Wed May 08, 2019 10:54 am
Re: LCD 1602 - Library
hi robert... now i can see text on lcd after updating with 39. is it possible to scroll the text on lcd from right to left or left to right?
Re: LCD 1602 - Library
The LCD displays are quite primitive. Here's a couple of references to the commands that can be sent to the LCD:
http://web.alfredstate.edu/faculty/weimandn/index.html
https://dawes.wordpress.com/2010/01/05/ ... ction-set/
The typical way to achieve scrolling is to write new text which is scrolled. i. Send "This is a test t" the first time and then after a delay, send "his is a test to" to scroll 1 character left (positioning the cursor before sending each string).
The display is capable of doing some hardware scrolling, but as you can see on this page: http://web.alfredstate.edu/faculty/weim ... index.html the memory arrangement isn't all that straight forward.
http://web.alfredstate.edu/faculty/weimandn/index.html
https://dawes.wordpress.com/2010/01/05/ ... ction-set/
The typical way to achieve scrolling is to write new text which is scrolled. i. Send "This is a test t" the first time and then after a delay, send "his is a test to" to scroll 1 character left (positioning the cursor before sending each string).
The display is capable of doing some hardware scrolling, but as you can see on this page: http://web.alfredstate.edu/faculty/weim ... index.html the memory arrangement isn't all that straight forward.
-
- Posts: 51
- Joined: Wed May 08, 2019 10:54 am
Re: LCD 1602 - Library
Hi dhylands.....thank you for sharing the links. i gone through those links and i am not able to get the code to scroll the text. it will be more helpful if i get some code to scroll the text on LCD.dhylands wrote: ↑Mon Jun 10, 2019 5:58 pmThe LCD displays are quite primitive. Here's a couple of references to the commands that can be sent to the LCD:
http://web.alfredstate.edu/faculty/weimandn/index.html
https://dawes.wordpress.com/2010/01/05/ ... ction-set/
The typical way to achieve scrolling is to write new text which is scrolled. i. Send "This is a test t" the first time and then after a delay, send "his is a test to" to scroll 1 character left (positioning the cursor before sending each string).
The display is capable of doing some hardware scrolling, but as you can see on this page: http://web.alfredstate.edu/faculty/weim ... index.html the memory arrangement isn't all that straight forward.
Re: LCD 1602 - Library
Here's an example which scrolls text (using the GPIO version). I recorded a video here: https://www.youtube.com/watch?v=KiR-r8mXBCo
Code: Select all
def test_main():
"""Test function for verifying basic functionality."""
print("Running test_main")
lcd = GpioLcd(rs_pin=Pin.cpu.C6,
enable_pin=Pin.cpu.C8,
d4_pin=Pin.cpu.C2,
d5_pin=Pin.cpu.C3,
d6_pin=Pin.cpu.C4,
d7_pin=Pin.cpu.C5,
num_lines=2, num_columns=16)
lcd.putstr("It Works!\nSecond Line\nThird Line\nFourth Line")
delay(3000)
lcd.clear()
msg = 'This is a scrolling test. '
if (len(msg) < lcd.num_columns):
msg += ' ' * (lcd.num_columns - len(msg))
for i in range(len(msg)):
len2 = min(lcd.num_columns, len(msg) - i)
len1 = lcd.num_columns - len2
msg2 = ''
if len2 > 0:
msg2 += msg[i:i+len2]
if len1 > 0:
msg2 += msg[0:len1]
lcd.move_to(0, 0)
lcd.putstr(msg2)
delay(250)
delay(1000)
lcd.clear()
count = 0
while True:
lcd.move_to(0, 0)
lcd.putstr("%7d" % (millis() // 1000))
delay(1000)
count += 1
-
- Posts: 51
- Joined: Wed May 08, 2019 10:54 am
Re: LCD 1602 - Library
Thank you dhylands...i will try and get back to you if have any questions.dhylands wrote: ↑Tue Jun 11, 2019 5:23 pmI recorded a video here: https://www.youtube.com/watch?v=KiR-r8mXBCo
-
- Posts: 51
- Joined: Wed May 08, 2019 10:54 am
Re: LCD 1602 - Library
dhylands wrote: ↑Tue Jun 11, 2019 5:23 pmHere's an example which scrolls text (using the GPIO version).Code: Select all
def test_main(): """Test function for verifying basic functionality.""" print("Running test_main") lcd = GpioLcd(rs_pin=Pin.cpu.C6, enable_pin=Pin.cpu.C8, d4_pin=Pin.cpu.C2, d5_pin=Pin.cpu.C3, d6_pin=Pin.cpu.C4, d7_pin=Pin.cpu.C5, num_lines=2, num_columns=16) lcd.putstr("It Works!\nSecond Line\nThird Line\nFourth Line") [/quote] Hi dhylands, i am trying below code to display text with GpioLcd. but text was not displaying on lcd screen so i stopped going further. do i need to change the pins in below code or do i need to change slc and sda pins. currently i am running below code after connecting slc =Pin(5) sda=Pin(4) from i2c to esp8266. i used lcd.clear() to clear the screen but it is not happening. from machine import Pin from nodemcu_gpio_lcd import GpioLcd lcd = GpioLcd(rs_pin=Pin(16),enable_pin=Pin(5),d4_pin=Pin(4),d5_pin=Pin(0),d6_pin=Pin(2),d7_pin=Pin(14),num_lines=2, num_columns=16) lcd.putstr("Hello")