Home > other >  SCM answer the lcd1602. The great god for help and have a look, chicken dishes I write a mess...
SCM answer the lcd1602. The great god for help and have a look, chicken dishes I write a mess...

Time:09-16

In monolithic integrated circuit P3.0, external P3.1 pin two separate keys K1, K2, K1 press when the first line cycle display your name pinyin, K2 press when the second line cycle show your student id, display interval of 1 second, the initial display "my information"


#include//the header file
# define uchar unsigned char//variable definition
# define uint unsigned int
Sbit RS=P2 ^ 0;
Sbit RW=P2 ^ 1;
Sbit EN=P2 ^ 2;
Sbit K1=P3 ^ 0;
Sbit K2=P3 ^ 1;
Uchar code table [4] [4]={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66,
X07 x6d 0, 0 x7d, 0, 0 x7f, 0 x6f,
X7c 0 x77, 0, 0 x39, 0 x5e, 0 x79, 0 x71};
Void delayms (uint z)
{
Uint x, y;
For (x=z; x> 0; X -)
For (y=114; Y> 0; Y -);//delay statements
}
Void lcd_status ()//read/write test
{
Uchar sta.
P0=0 XFF;//input state
RS=0;
RW=1;
EN=0;
Do
{
EN=1;
The sta=P0;
EN=0;
} while (sta& 0 x80);
}
Void lcd_writecmd uchar (CMD)
{
Lcd_status ();
RS=1;
RW=0;
P0=CMD;
EN=1;
EN=0;
}
Void lcd_writedate uchar (dat)
{
Lcd_status ();
RS=1;
RW=0;
P0=dat;
EN=1;
EN=0;
}
Void lcd1602_init ()
{
X38 lcd_writecmd (0);//16 * 2, 5 * 7 lattice, 8 bits of data port
X0c lcd_writecmd (0);//display, cursor blink, the cursor displays
X07 lcd_writecmd (0);//the screen left a
Lcd_writecmd (0 x01);//data pointer, all show zero
}
Void main ()
{
Lcd1602_init ();
Lcd_writecmd (0 x80 + 0 x06);
While (1);
}







CodePudding user response:

First without buttons, direct display a line of characters to see success, add button again, I think you did not even realize display,
  • Related