LCD with character display I LOVE YOU

Publisher:EnchantedBreezeLatest update time:2024-08-15 Source: cnblogsKeywords:LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1602 is a character LCD, which contains a character library of 128 ASCII characters, so it can display ASCII characters but not Chinese characters.


1602 can display two lines of information, 16 characters per line, powered by 5V power supply and with backlight.


Knowledge points:

#include

#include

#define uchar unsigned char

#define LCD P2

sbit RS = P3^0;

sbit RW = P3^1;

sbit E = P3^2;

uchar i,j;

uchar tab[] = "I LOVE YOU"; //Define an array and put the characters to be displayed into the array

void writeCMD(uchar cmd)

{

RS = 0; //0 represents command, 1 represents data write command

RW = 0; //0 represents write, 1 represents read

for(i=0;i<200;i++);//Small delay

LCD = cmd; //write command

E = 1; //LCD enable

for(i=0;i<5;i++);//Small delay

E = 0; //Disable LCD

for(i=0;i<5;i++);//Small delay

}

void writeDATA(uchar data1) //write data

{

RS = 1; //0 represents command, 1 represents data write data

RW = 0; //0 represents write, 1 represents read

for(i=0;i<200;i++);//Small delay

LCD = data1; //write command

E = 1;

for(i=0;i<5;i++);//Small delay

E = 0;

for(i=0;i<5;i++);//Small delay

}


//LCD initialization, hardware fixed initialization steps, no need to remember


void init()

{

RW = 0; //Low level makes write operation effective

E = 0; // Enable LCD

writeCMD(0x38); //16*2 display, 5*7 dot matrix, 8-bit data interface

writeCMD(0x0C); //Open the display, but do not display the cursor

writeCMD(0x06); //After reading or writing a character, the address pointer is incremented by 1, and the cursor is incremented by 1; when writing a character, the entire screen display does not move

writeCMD(0x01); //Clear screen

}

//Main function

void main(void)

{

init(); //LCD initialization sub-function call

writeCMD(0xc0); //Write address, choose where to display characters on the screen

for(i=0;i<220;i++);//Small delay

for(j=0;j<10;j++)//for loop displays multiple characters in sequence

writeDATA(tab[j]); //Characters to be displayed on the screen

while(1);

}

Wireless label included:

Click LBL, double-click on the two ends of the wireless connection, and attach the same name.


Keywords:LCD Reference address:LCD with character display I LOVE YOU

Previous article:80C31 MCU external interrupt 0
Next article:External interrupt 0/1

Latest Microcontroller Articles
Change More Related Popular Components

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号