I recently followed the Adafuit instructions for wiring up a 16x2 LCD and printing statements/info to the LCD.
I was able to successfully wire, and display text on the LCD, but the text eventually starts getting corrupted.
I printed the single statement "Test Message" and saw it clearly for 2 seconds (which is how long the program runs the message for before "Clearing" the display and running again.) However, after the 2 seconds, I now see "cggvgsv"ogsscggv" displayed. I'm using an RPi Zero W. Here is the code I am using:
Code: Select all
#!/usr/bin/python
from Adafruit_CharLCD import Adafruit_CharLCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime
# pin configuration and 16x2 setup. Pin numbers are (BCM)
lcd_rs = 25
lcd_en = 24
lcd_d4 = 23
lcd_d5 = 17
lcd_d6 = 21
lcd_d7 = 22
#0=Off, 4=On
lcd_backlight = 4
lcd_columns = 16
lcd_rows = 2
# Initialize the display and begin
lcd = Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
while True:
lcd.clear()
lcd.message("Test Message")
sleep(2)