Home > Microcontroller >Interface Circuits > Tutorial on using 8051 microcontroller to display content on LCD screen

Tutorial on using 8051 microcontroller to display content on LCD screen

Source: InternetPublisher:抄写员 Keywords: Liquid crystal display LCD microcontroller Updated: 2025/02/14

Liquid Crystal Display (LCD) is a commonly used display screen that is often used in many electronic products to display information in text or image format. LCD is used to display characters such as letters, numbers, etc. on its screen. LCD display consists of 8 data lines and 3 control lines, which are used to connect LCD display with 8051 microcontroller.

Consider using Proteus based analog LCD to interface with 8051 microcontroller:

embedded-system-lcd-programmming1.png

How to display "8051 microcontroller" on the LCD display, the case program is as follows:

#include< reg51.h >#define kam P0void lcd_initi();
void lcd_dat(unsigned char );
void lcd_cmd(unsigned char );
void delay();
void display(unsigned char *s, unsigned char r)
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
void main(){
lcd_initi();
lcd_cmd(0x80);
delay(100);
lcd_cmd(0xc0);
display("8051 MCU",10);
while(1);
}
void display(unsigned char *s, unsigned char r){
unsignedint w;
for(w=0;w<r;w++)
{
lcd_data(s[w]);
}
}
void lcd_initi()
{
lcd_cmd(0x01);
delay(100);
lcd_cmd(0x38);
delay(100);
lcd_cmd(0x06);
delay(100);
lcd_cmd(0x0c);
delay(100);
}
voidlcd_dat(unsigned char dat)
{
kam = dat;
rs=1;
rw=0;
en=1;
delay(100);
en=0;
}
}
voidlcd_cmd(unsigned char cmd)
{
kam=cmd;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}
void delay( unsigned int n){
unsignedint a;
for(a=0;a<n;a++);}

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号