LCD12864串行和并行显示

一、LCD12864串行显示

***********************************************************************/
#include 
#include 

#define uchar unsigned char
#define uint  unsigned int

sbit CS   = P2^4;
sbit SID  = P2^5;
sbit SCLK = P2^6;	
sbit RST  = P2^3;
sbit CH   = P2^1;

void delay(unsigned int t)
{
	unsigned int i,j;
	for(i=0; i
{  
    while(*s > 0)
    { 
	write_data(*s);
	s++;
	delay(50);
    }
}
void Test()
{  
	write_com(0x03);
	delay(50);    
	write_com(0x81);
	hzkdis("  LCD12864");
}
void Main()
{ 
	CH = 0;
	delay(1);
	lcdinit();
	delay(10);
	while(1)
	{
		Test();
		delay(5000);
        	delay(5000);
	}
}
 
  
 
  
 
  
 
  
 
  
 
  

二、LCD12864并行显示

//***********************************************************************/
#include 
#include 

#define uchar unsigned char
#define uint  unsigned int

uchar code IC_DAT[];
uchar code pic1[];
uchar code pic2[];
uchar code pic3[]; 

sbit RS  = P2^4;
sbit WRD = P2^5;
sbit E   = P2^6;

sbit PSB = P2^1; sbit RES = P2^3;

void TransferData(char data1,bit DI);

void display(void); void display_grapic(void);

void delayms(uint n);
void DisplayGraphic(uchar code *adder);
void delay(uint m);
void lcd_mesg(uchar code *adder1);
void DisplayLine(uchar line1,uchar line2);

uchar code IC_DAT[]={
"     HOT-51     "  
"                "
"                "
"                "
};
uchar code IC_DAT2[]={
"12               "			//0x80
"34               "			//0x90
"56               "			//0x88
"78               "			//0x98
};
unsigned char Convert(unsigned char In_Date)
{
    unsigned char i, Out_Date = 0, temp = 0;
    for(i=0; i<8; i++)
    {
        temp = (In_Date >> i) & 0x01;
        Out_Date |= (temp << (7 - i));
    }
    return Out_Date;
}
void initinal(void)
{
    delay(40);  
    PSB=1;   
    delay(1); 
    RES=0;  
    delay(1);
    RES=1;  
    delay(10);
    TransferData(0x30,0); 
    delay(100);           
    TransferData(0x30,0);  
    delay(37);          
    TransferData(0x08,0);
    delay(100); 
    TransferData(0x10,0);
    delay(100);
    TransferData(0x0C,0);
    delay(100); 
    TransferData(0x01,0); 
    delay(10); 
    TransferData(0x06,0);
    delay(100);  
}
void initina2(void) 
{
    delay(40);
    PSB=1;
    delay(1);
    RES=0; 
    delay(1);
    RES=1; 
    delay(10);
    TransferData(0x36,0); 
    delay(100);
    TransferData(0x36,0);
    delay(37);
    TransferData(0x3E,0); 
    delay(100);
    TransferData(0x01,0);
    delay(100);
}
void main(void)
{
    while(1)
    {
        initina2();
        DisplayGraphic(pic2);
        delayms(200);			  
        initinal(); 
        delay(100); 
        lcd_mesg(IC_DAT);
        delayms(240);
        delayms(240);
        initinal(); 
        delay(100);
        lcd_mesg(IC_DAT2);
        delayms(240);
        delayms(240);
        initinal();  
    }
}
void   lcd_mesg(unsigned char code *adder1)
{
    unsigned char i;
    TransferData(0x80,0); 
    delay(100);
    for(i=0;i<32;i++)
    {
        TransferData(*adder1,1);
        adder1++;
    }
    TransferData(0x90,0);
    delay(100);
    for(i=32;i<64;i++)
    {
        TransferData(*adder1,1);
        adder1++;
    }
}
void TransferData(char data1,bit DI)
{
    WRD=0;
    RS=DI;
    delay(1);
    P0=Convert(data1);
    E=1;
    delay(1);
    E=0;
}
void delayms(unsigned int n) 
{
    unsigned int i,j;
    for(i=0;i

 
  

 
  


你可能感兴趣的:(51单片机)