新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機實驗板2011_V1.1-LCD12864液晶顯示

單片機實驗板2011_V1.1-LCD12864液晶顯示

作者: 時間:2016-11-18 來源:網(wǎng)絡(luò) 收藏

/***********************************************************/
/*模塊名 :LCD12864控制顯示 */
/*創(chuàng)建人 :ClimberWin 日期:2011-03-12 */
/***********************************************************/

本文引用地址:http://m.butianyuan.cn/article/201611/316041.htm

#include
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long

sbit LCD_CS = P1^5;//片選 高電平有效 單片LCD使用時可固定高電平 rs
sbit LCD_SID = P1^6;//數(shù)據(jù) r/w
sbit LCD_SCLK = P1^7;//時鐘 e


ucharcode HEX_[] ={"0123456789ABCDEF"};

uchar BUFFER[6] = {0};
uchar K_NUM;
void DELAY(uchar t);
void LCD_SEND(uchar date);
void LCD_SCOM(bit st,uchar date);
void LCD_DELAY(void);
void LCD_INIT(void);
void LCD_write(uchar *p);
void LCD_LOCAL(uchar x,uchar y,uchar *p);
void LCD_cblank(uchar x,uchar y);
void LCD_count(long s,uchar x1,uchar y1,uchar x,uchar y,uchar *p);
void LCD_bai();
void Delay1ms(unsigned int count);
/***************************1秒延時子程序start***************************/
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;ifor(j=0;j<120;j++);
}

/***************************1秒延時子程序end***************************/

void DELAY(uchar t)
{
while(--t);
}
void LCD_SEND(uchar date)
{
uchar i;
LCD_SCLK=0;
for(i=0;i<8;i++)
{
LCD_SID=date&0x80;
LCD_SCLK=1;
LCD_SCLK=0;
date<<=1;
}
}
void LCD_SCOM(bit st,uchar date)
{
uchar st_temp,hdate,ldate;
if(st)
st_temp=0xfa;
else st_temp=0xf8;
hdate=date&0xf0;
ldate=date&0x0f;
ldate <<= 4;
LCD_CS = 1;
LCD_SEND(st_temp);
LCD_SEND(hdate);
LCD_SEND(ldate);
LCD_CS = 0;
DELAY(38);
}
void LCD_DELAY(void)
{ uchar s;
s=10;
while(--s)
DELAY(250);
}
void LCD_INIT(void)
{
LCD_SCOM(0,0x30);
LCD_DELAY();
LCD_SCOM(0,0x0c);
LCD_DELAY();
LCD_SCOM(0,0x01); //清屏,將DDRAM的地址計數(shù)器歸零
LCD_DELAY();
}
void LCD_write(uchar *p)
{
while(*p)
{
LCD_SCOM(1,*p);
p++;
}
}
void LCD_LOCAL(uchar x,uchar y,uchar *p) //lcd string (x,y) write!
{
switch (x)
{
case 1:LCD_SCOM(0,0x7f+y); LCD_write(p);break;
case 2:LCD_SCOM(0,0x8f+y); LCD_write(p);break;
case 3:LCD_SCOM(0,0x87+y); LCD_write(p);break;
case 4:LCD_SCOM(0,0x97+y); LCD_write(p);break;
default :LCD_SCOM(0,0x7f+y); LCD_write(p);
}
}
void LCD_cblank(uchar x,uchar y)
{
switch (x)
{
case 1:LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);break;
case 2:LCD_SCOM(0,0x8f+y); LCD_SCOM(0,0x0d);break;
case 3:LCD_SCOM(0,0x87+y); LCD_SCOM(0,0x0d);break;
case 4:LCD_SCOM(0,0x97+y); LCD_SCOM(0,0x0d);break;
default :LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);
}
}

/*******************************************/

/********************************************/
main()
{ //main start

Delay1ms(1000);
LCD_INIT();
Delay1ms(1000);
LCD_LOCAL(1,1,"單片機教學(xué)實驗板");
LCD_LOCAL(2,1,"LCD12864顯示程序");
LCD_LOCAL(3,1,"版本:V1.1 ");
LCD_LOCAL(4,1,"2011年03月12日 ");

while(1);

}



關(guān)鍵詞: 單片機LCD12864液晶顯

評論


技術(shù)專區(qū)

關(guān)閉