Aula Jazmati
Published

Interfacing 16×2 LCD in Raspberry Pi Using Python & Tk Tools

In this project, I go through the steps on how to set up a Raspberry Pi LCD 16×2 to display messages from the Pi Tkinter GUI.

IntermediateFull instructions provided1 hour3,177
Interfacing 16×2 LCD in Raspberry Pi Using Python & Tk Tools

Things used in this project

Story

Read more

Custom parts and enclosures

The Project file

Schematics

Circuit Diagram

Code

aaa.py

Python
from tkinter import *
import time
import Adafruit_CharLCD as LCD
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,False)
lcd_rs        = 27
lcd_en        = 22
lcd_d4        = 25
lcd_d5        = 24
lcd_d6        = 23
lcd_d7        = 18
lcd_backlight = 4
lcd_columns = 16
lcd_rows    = 2
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,lcd_columns, lcd_rows, lcd_backlight)
#lcd.message('Hello\nworld!')
#time.sleep(5.0)
lcd.clear()
#lcd.show_cursor(True)
def show_entry_fields():
                           print(e1.get())
                           lcd.message(e1.get())
                           
                           GPIO.output(17,True)
                           time.sleep(60.0)
                           lcd.clear()
                           GPIO.output(17,False)
master = Tk()
s=Label(master,font = "Times 16 bold",text="Your Message:")
s.pack()
e1 = Entry(master)
e1.pack()
b1 =Button(master,text='Quit', bg ='yellow', font = "Times 16 bold", command=master.quit)
b1.pack(side =LEFT)
b2=Button(master,text='Show', fg ='yellow',bg='purple',  font = "Times 16 bold",command=show_entry_fields)
b2.pack(side = RIGHT)
mainloop()

Credits

Aula Jazmati

Aula Jazmati

49 projects • 193 followers
(PhD) in Electronic Engineering 2023 💡🕊️

Comments