The Seller Does Not Bear the Return Shipping Fee.£¬No Technical Support No Technical Information Is Provided.£¬Please Choose Carefully before Purchasing£¡
LCD1602(Yellow Green Screen)
Standard Type16X2LCD Character Module£¨Backlight/Yellow Green£©
1602Standard16Foot Interface£¬Which:
First1Feet£ºVSSGround Power Supply
First2Feet£ºVDDPick up5VPositive Power Supply
First3Feet£ºV0Contrast Control-End LCD£¬The Contrast Is the Weakest When the Positive Power Source Is Connected.£¬The Contrast Ratio Is the Highest When Grounding Power Supply£¬When the Contrast Is Too High, It Will Occur.“Ghost Shadow”£¬You Can Use One10KPotentiometer to Adjust Contrast
First4Feet£ºRSSelect for Register£¬Select a Data Register at High Level¡¢Select Instruction Register at Low Level¡£
First5Feet£ºR/WRead/Write Signal Line£¬Read at High Level£¬Write at Low Level¡£WhenRSandRWThe Command Or Display Address Can Be Written When the Common Power Is Low.£¬WhenRSLow LevelRWYou Can Read Busy Signals When It Is High.£¬WhenRSHighRWData Can Be Written When It Is Low¡£
First6Feet£ºEEnable End£¬WhenEWhen the Terminal Jumps from High Level to Low Level£¬LCD Module Execution Command¡£
First7¢¦14Feet£ºD0¢¦D7For8Bit Bidirectional Data Cable¡£
First15Feet£ºBacklight Power Positive Pole
First16Feet£ºBacklight Power Negative Pole
1602Character Generation Memory inside LCD Module£¨CGROM)Already Stored160Different Dot Matrix Characters£¬Such as Table1As Shown in£¬These Characters Include£ºArabic Numerals¡¢Case of English Letters¡¢Common Symbols¡¢And Japanese Kana, Etc.£¬Each Character Has a Fixed Code.£¬For Example, Uppercase English Letters“A”The Code Is01000001B£¨41H£©£¬Module Address When Displaying41HThe Dot Matrix Character Graph in Is Displayed.£¬We Can See Letters“A” ¡£
The following Shows the Letters in the Position of the First Character in the Second Line of the LCD Module.“A”Program£º ORG 0000H
RS EQU P3.7;Determine the Connection Method of Specific Hardware
RW EQU P3.6 ;Determine the Connection Method of Specific Hardware
E EQU P3.5 ;Determine the Connection Method of Specific Hardware
MOV P1,#00000001B £»Clear the Screen and Reset the Cursor
ACALL ENABLE;Call the Write Command Subprogram
MOV P1,#00111000B £»Set Display Mode:8Bit2Line5x7Dot Matrix
ACALL ENABLE ;Call the Write Command Subprogram
MOV P1,#00001111B £»Monitor on¡¢Cursor Open¡¢Allow the Cursor to Blink
ACALL ENABLE ;Call the Write Command Subprogram
MOV P1,#00000110B £»Text Does Not Move£¬The Cursor Automatically Moves to the Right.
ACALL ENABLE ;Call the Write Command Subprogram
MOV P1,#0C0H £»Write Display Start Address£¨The First Position in the Second Row£©
ACALL ENABLE ;Call the Write Command Subprogram
MOV P1,££01000001B £»LetterAThe Code
SETB RS £»RS=1
CLR RW £»RW=0 ;Prepare to Write Data
CLR E £»E=0 ;Run the Display Command
ACALL DELAY ;Determine Whether the LCD Module Is Busy?
SETB E £»E=1 ;Display Complete,Program Parking
AJMP $
ENABLE:
CLR RS £»Subprogram for Writing Control Commands
CLR RW
CLR E
ACALL DELAY
SETB E
RET
DELAY:
MOV P1,#0FFH £»Subprogram for Determining Whether the LCD Is Busy
CLR RS
SETB RW
CLR E
NOP
SETB E
JB P1.7,DELAY £»IfP1.7A High Level Indicates That a Busy Cycle Waits.
RET
END
The Program Initializes the LCD Module Function at the Beginning.£¬Agreed Display Format¡£Note That the Display Character Time Mark Is Automatically Shifted to the Right.£¬No Manual Intervention Required£¬Each Input Instruction Calls a Subprogram to Determine Whether the LCD Module Is Busy.DELAY£¬Then Enter the Address of the Display Location.0C0H£¬Finally, Enter the Characters to Be Displayed.AThe Code41H¡£
SMC1602A(16*2)Wiring Mode of Analog Port Line
Connecting Line Diagram:
---------------------------------------------------
LCM-----51 LCM-----51 LCM------51
------------------------------------------------
DB0-----P1.0 DB4-----P1.4 RW-------P2.0
DB1-----P1.1 DB5-----P1.5 RS-------P2.1
DB2-----P1.2 DB6-----P1.6 E--------P2.2
DB3-----P1.3 DB7-----P1.7 VLCDPick up1KResistanceGND
---------------------------------------------------
[Note:AT89S52Use12MCrystal Oscillator]
=============================================================*/
#define LCM_RW P2_0 //Define Pin
#define LCM_RS P2_1
#define LCM_E P2_2
#define LCM_Data P1
#define Busy 0x80 //Used for DetectionLCMIn the Status WordBusyIdentification
££i nclude
void WriteDataLCM(unsigned char WDLCM);
void WriteCommandLCM(unsigned char WCLCM,BuysC);
unsigned char ReadDataLCM(void);
unsigned char ReadStatusLCM(void);
void LCMInit(void);
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData);
void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData);
void Delay5Ms(void);
void Delay400Ms(void);
unsigned char code uctech[] = {"uctech"};
unsigned char code net[] = {"uctech.icpcn.com"};
void main(void)
{
Delay400Ms(); //Start Waiting£¬and OtherLCMSpeak in Working Status
LCMInit(); //LCMInitialization
Delay5Ms(); //Delay a Moment(Don`t)
DisplayListChar(0, 5, uctech);
DisplayListChar(0, 0, net);
ReadDataLCM();//Test Sentence Meaningless
while(1);
}
//Write Data
void WriteDataLCM(unsigned char WDLCM)
{
ReadStatusLCM(); //Detection Busy
LCM_Data = WDLCM;
LCM_RS = 1;
LCM_RW = 0;
LCM_E = 0; //If the Crystal Oscillator Speed Is Too High, a Small Delay Can Be Added after This
LCM_E = 0; //Delay
LCM_E = 1;
}
//Write Instruction
void WriteCommandLCM(unsigned char WCLCM,BuysC) //BuysCFor0Ignore Busy Detection
{
if (BuysC) ReadStatusLCM(); //Check Busy as Needed
LCM_Data = WCLCM;
LCM_RS = 0;
LCM_RW = 0;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
}
//Read Data
unsigned char ReadDataLCM(void)
{
LCM_RS = 1;
LCM_RW = 1;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
return(LCM_Data);
}
//Read Status
unsigned char ReadStatusLCM(void)
{
LCM_Data = 0xFF;
LCM_RS = 0;
LCM_RW = 1;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
while (LCM_Data & Busy); //Detect Busy Signals
return(LCM_Data);
}
void LCMInit(void) //LCMInitialization
{
LCM_Data = 0;
WriteCommandLCM(0x38,0); //Three Display Mode Settings£¬Do Not Detect Busy Signals
Delay5Ms();
WriteCommandLCM(0x38,0);
Delay5Ms();
WriteCommandLCM(0x38,0);
Delay5Ms();
WriteCommandLCM(0x38,1); //Display Mode Settings,It Is Required to Detect Busy Signals Every Time.
WriteCommandLCM(0x08,1); //Turn off Display
WriteCommandLCM(0x01,1); //Display Clear Screen
WriteCommandLCM(0x06,1); // Display Cursor Movement Settings
WriteCommandLCM(0x0C,1); // Display on and Cursor Setting
}
//Displays a Character at a Specified Position.
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
{
Y &= 0x1;
X &= 0xF; //LimitXCannot Be Greater15£¬YCannot Be Greater1
if (Y) X = 0x40; //When the Second Row Address Code Is to Be Displayed+0x40;
X = 0x80; // Calculate the Instruction Code
WriteCommandLCM(X, 0); //No Busy Signal Is Detected Here.£¬Send Address Code
WriteDataLCM(DData);
}
//Displays a String of Characters at a Specified Location.
void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData)
{
unsigned char ListLength;
ListLength = 0;
Y &= 0x1;
X &= 0xF; //LimitXCannot Be Greater15£¬YCannot Be Greater1
while (DData[ListLength]>0x20) //Exit If the End of the String Is Reached
{
if (X <= 0xF) //XCoordinates Should Be Less0xF
{
DisplayOneChar(X, Y, DData[ListLength]); //Display a Single Character
ListLength++;
X++;
}
}
}
//5msDelay
void Delay5Ms(void)
{
unsigned int TempCyc = 5552;
while(TempCyc--);
}
//400msDelay
void Delay400Ms(void)
{
unsigned char TempCycA = 5;
unsigned int TempCycB;
while(TempCycA--)
{
TempCycB=7269;
while(TempCycB--);
};
The above Procedures Are for Reference Only.£¡£¡