I was searching for the 16x2 LCD Interfacing with Raspberry Pi and found that there are not many Instructions About interfacing the simple Connection anywhere in the Community Blogs Hence, I decided to create a small instruction to interface the LCD with Raspberry Pi using Adafruit CharLCD Library.
To interface the LCD with Raspberry Pi we need to install The Circuit Python and CharLCD Library.
- Firstly, you need to install the circuit python Libraries. The following Link shows How to Install Circuit Python On the raspberry pi platform https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi
- Then You need to install CharLCD Libraries by following the link. https://learn.adafruit.com/character-lcds/python-circuitpython
Raspberry Pi to 16X2 LCD Pin Connections
Raspberry Pi Pins | LCD Pins |
GPIO26 | RS |
GPIO19 | EN |
GPIO25 | D4 |
GPIO24 | D5 |
GPIO 22 | D6 |
GPIO27 | D7 |
Circuit Connection Diagram
Simple Example code To display a message On LCD With Cursors Position Pointer
import time import board import digitalio import adafruit_character_lcd.character_lcd as characterlcd # Modify this if you have a different sized character LCD lcd_columns = 16 lcd_rows = 2 # Raspberry Pi Pin Config: lcd_rs = digitalio.DigitalInOut(board.D26) lcd_en = digitalio.DigitalInOut(board.D19) lcd_d7 = digitalio.DigitalInOut(board.D27) lcd_d6 = digitalio.DigitalInOut(board.D22) lcd_d5 = digitalio.DigitalInOut(board.D24) lcd_d4 = digitalio.DigitalInOut(board.D25) lcd_backlight = digitalio.DigitalInOut(board.D4) # Initialise the lcd class lcd = characterlcd.Character_LCD_Mono( lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight ) lcd.cursor_position(0, 0)# coloumn,row lcd.message = "HI," lcd.cursor_position(3, 0)# coloumn,row lcd.message = "Hope you are" lcd.cursor_position(0, 1) lcd.message = "Seeing The Video" time.sleep(5) lcd.clear() lcd.cursor_position(0, 0)# coloumn,row lcd.message = "Raspberry Pi " lcd.cursor_position(0, 1)# coloumn,row lcd.message = "LCD Interfacing" time.sleep(5) lcd.clear()
Raspberry Pi 16x2 LCD Interfacing Result Video