單片機(jī)驅(qū)動(dòng)19264液晶顯示漢字c程序
19264液晶是一種比12864大一點(diǎn)點(diǎn)的單色液晶,這里我給大家介紹一下用stc系列單片機(jī)驅(qū)動(dòng)他顯示漢字的原理
效果圖
由于網(wǎng)頁空間篇幅有限本文只列出了部分代碼,完整版本請(qǐng)從http://www.51hei.com/f/19264.rar處下載
#includestc89.h>#includeintrins.h>#define uchar unsigned char#define uint unsigned intuint ee;uchar f;sbit lcd_cs3=P1^0;//片選信號(hào)右 低有效sbit lcd_cs2=P1^1;//片選信號(hào)中 低有效sbit lcd_cs1=P1^2;//片選信號(hào)左 低有效sbit lcd_e =P1^3;//使能信號(hào)sbit lcd_rw =P1^4;//讀寫選擇sbit lcd_rs =P1^5;//數(shù)據(jù)命令選擇端 H數(shù)據(jù) L命令sbit lcd_rst=P1^6;// 液晶復(fù)位引腳 低有效 低的話 就一直復(fù)位了//P2八位數(shù)據(jù)線uchar code cc[]={/*---------------小----------------*/0xFF,0xFF,0xFF,0xFF,0xBF,0xDF,0xEF,0xE7,0xF3,0xF9,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFE,0xFE,0xF6,0xF2,0xE6,0xEE,0xDE,0xBE,0x7E,0xFE,0xFE,0xFE,0xFA,0xFD,/*---------------鵬----------------*/0xEF,0xDF,0x83,0x9B,0xAB,0xAB,0xB3,0xBF,0x81,0xFD,0xFD,0x05,0xFD,0xEB,0xF7,0xFF,0xFF,0x88,0xAA,0xAA,0x88,0xAA,0xAA,0xAA,0x88,0xAA,0xAA,0xAA,0xAA,0x46,0xEC,0xFF,/*---------------工----------------*/0xFF,0xFF,0xFF,0xF7,0xF7,0xF7,0xF7,0x07,0xFB,0xFB,0xFB,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xF0,0xF7,0xF7,0xF7,0xF7,0xF7,0xF7,0xFF,0xFF,/*---------------作----------------*/0x7F,0xBF,0xDF,0x07,0xF8,0xBF,0xCF,0xE3,0x0C,0x6F,0x6F,0xB7,0xB7,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0xFF,0xFF,0xFF,0xFF,0x80,0xFB,0xFB,0xFD,0xFD,0xFD,0xFF,0xFF,/*---------------室----------------*/0xFF,0xFF,0xE7,0xD7,0x57,0x97,0xD6,0xD9,0x6B,0x6B,0x2B,0x73,0xFB,0xFF,0xFF,0xFF,0xFF,0xBF,0xBF,0xB6,0xB6,0xB6,0xB6,0xC0,0xDB,0xDB,0xDB,0xDE,0xDF,0xFF,0xFF,0xFF,/*---------------開----------------*/0xFF,0x7F,0x7F,0x7B,0x7B,0x03,0xBD,0xBD,0xBD,0x01,0xBD,0xBD,0xBF,0xBF,0xFF,0xFF,0xFF,0xBF,0xDF,0xEF,0xF3,0xFC,0xFF,0xFF,0xFF,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*---------------發(fā)----------------*/0xFF,0xFF,0xDF,0xC1,0xDF,0x1F,0x60,0x6F,0x6F,0xAD,0x2B,0xEF,0xEF,0xFF,0xFF,0xFF,0xDF,0xEF,0xB7,0xBB,0xDC,0xDD,0xEB,0xF7,0xF3,0xED,0xDE,0xBF,0xBF,0xBF,0xFF,0xFF,/*-------------------------------*/0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,};uchar code dd[]={/*---------------小----------------*/0x00,0x00,0x00,0x00,0x40,0x20,0x10,0x18,0x0C,0x06,0x04,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x09,0x0D,0x19,0x11,0x21,0x41,0x81,0x01,0x01,0x01,0x05,0x02,/*---------------鵬----------------*/0x10,0x20,0x7C,0x64,0x54,0x54,0x4C,0x40,0x7E,0x02,0x02,0xFA,0x02,0x14,0x08,0x00,0x00,0x77,0x55,0x55,0x77,0x55,0x55,0x55,0x77,0x55,0x55,0x55,0x55,0xB9,0x13,0x00,/*---------------工----------------*/0x00,0x00,0x00,0x08,0x08,0x08,0x08,0xF8,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x0F,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,/*---------------作----------------*/0x80,0x40,0x20,0xF8,0x07,0x40,0x30,0x1C,0xF3,0x90,0x90,0x48,0x48,0x08,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x7F,0x04,0x04,0x02,0x02,0x02,0x00,0x00,/*---------------室----------------*/0x00,0x00,0x18,0x28,0xA8,0x68,0x29,0x26,0x94,0x94,0xD4,0x8C,0x04,0x00,0x00,0x00,0x00,0x40,0x40,0x49,0x49,0x49,0x49,0x3F,0x24,0x24,0x24,0x21,0x20,0x00,0x00,0x00,/*---------------開----------------*/0x00,0x80,0x80,0x84,0x84,0xFC,0x42,0x42,0x42,0xFE,0x42,0x42,0x40,0x40,0x00,0x00,0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,/*---------------發(fā)----------------*/0x00,0x00,0x20,0x3E,0x20,0xE0,0x9F,0x90,0x90,0x52,0xD4,0x10,0x10,0x00,0x00,0x00,0x20,0x10,0x48,0x44,0x23,0x22,0x14,0x08,0x0C,0x12,0x21,0x40,0x40,0x40,0x00,0x00,};void lcd_init();void wrile_com(uchar com);void wrile_data(uchar dat);void QPCZ(uchar TT,rg) ; //液晶屏 清屏操作void XYZ(uchar q1,q2,q3);void delay(uchar d0);void main(){while(1){lcd_init();QPCZ(0x11,0xff); delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);QPCZ(0x00,0x00); XYZ(0xc0,0xb8,0x60);lcd_cs1=0;lcd_cs2=1;lcd_cs3=1;for(f=0;f224;f++){if(f==64){lcd_cs1=1;lcd_cs2=0;lcd_cs3=1;}if(f==192){lcd_cs1=1;lcd_cs2=1;lcd_cs3=0;}switch(f) // 括號(hào)里面的語句和 case比較{case 16:XYZ(0xc0,0xb9,0x60); //比較一樣 break;case 32:XYZ(0xc0,0xb8,0x70); //比較一樣 break;case 48:XYZ(0xc0,0xb9,0x70); //比較一樣 break;case 64:XYZ(0xc0,0xb8,0x40); //比較一樣 break;case 80:XYZ(0xc0,0xb9,0x40); //比較一樣 break;case 96:XYZ(0xc0,0xb8,0x50); //比較一樣 break;case 112:XYZ(0xc0,0xb9,0x50); //比較一樣 break;case 128:XYZ(0xc0,0xb8,0x60); //比較一樣 break;case 144:XYZ(0xc0,0xb9,0x60); //比較一樣 break;case 160:XYZ(0xc0,0xb8,0x70); //比較一樣 break;case 176:XYZ(0xc0,0xb9,0x70); //比較一樣 break;case 192:XYZ(0xc0,0xb8,0x40); //比較一樣 break;case 208:XYZ(0xc0,0xb9,0x40); //比較一樣 break;}// delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);wrile_data(cc[f]);}XYZ(0xc0,0xb8,0x60);lcd_cs1=0;lcd_cs2=1;lcd_cs3=1;XYZ(0xc0,0xb8,0x60);lcd_cs1=0;lcd_cs2=1;lcd_cs3=1;for(f=0;f224;f++){if(f==64){lcd_cs1=1;lcd_cs2=0;lcd_cs3=1;}if(f==192){lcd_cs1=1;lcd_cs2=1;lcd_cs3=0;}switch(f) // 括號(hào)里面的語句和 case比較{case 16:XYZ(0xc0,0xb9,0x60); //比較一樣 break;case 32:XYZ(0xc0,0xb8,0x70); //比較一樣 break;case 48:XYZ(0xc0,0xb9,0x70); //比較一樣 break;case 64:XYZ(0xc0,0xb8,0x40); //比較一樣 break;case 80:XYZ(0xc0,0xb9,0x40); //比較一樣 break;case 96:XYZ(0xc0,0xb8,0x50); //比較一樣 break;case 112:XYZ(0xc0,0xb9,0x50); //比較一樣 break;case 128:XYZ(0xc0,0xb8,0x60); //比較一樣 break;case 144:XYZ(0xc0,0xb9,0x60); //比較一樣 break;case 160:XYZ(0xc0,0xb8,0x70); //比較一樣 break;case 176:XYZ(0xc0,0xb9,0x70); //比較一樣 break;case 192:XYZ(0xc0,0xb8,0x40); //比較一樣 break;case 208:XYZ(0xc0,0xb9,0x40); //比較一樣 break;}//delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);wrile_data(dd[f]);}XYZ(0xc0,0xba,0x60);lcd_cs1=0;lcd_cs2=1;lcd_cs3=1;XYZ(0xc0,0xba,0x60);lcd_cs1=0;lcd_cs2=1;lcd_cs3=1;for(f=0;f224;f++){if(f==64){lcd_cs1=1;lcd_cs2=0;lcd_cs3=1;}if(f==192){lcd_cs1=1;lcd_cs2=1;lcd_cs3=0;}switch(f) // 括號(hào)里面的語句和 case比較{case 16:XYZ(0xc0,0xbb,0x60); //比較一樣 break;case 32:XYZ(0xc0,0xba,0x70); //比較一樣 break;case 48:XYZ(0xc0,0xbb,0x70); //比較一樣 break;case 64:XYZ(0xc0,0xba,0x40); //比較一樣 break;case 80:XYZ(0xc0,0xbb,0x40); //比較一樣 break;case 96:XYZ(0xc0,0xba,0x50); //比較一樣 break;case 112:XYZ(0xc0,0xbb,0x50); //比較一樣 break;case 128:XYZ(0xc0,0xba,0x60); //比較一樣 break;case 144:XYZ(0xc0,0xbb,0x60); //比較一樣 break;case 160:XYZ(0xc0,0xba,0x70); //比較一樣 break;case 176:XYZ(0xc0,0xbb,0x70); //比較一樣 break;case 192:XYZ(0xc0,0xba,0x40); //比較一樣 break;case 208:XYZ(0xc0,0xbb,0x40); //比較一樣 break;}// delay(250);delay(250);delay(250);delay(250);delay(250);delay(250);wrile_data(cc[f]);} QPCZ(0xff,0xff);delay(250);delay(250);delay(250);}}void lcd_init(){lcd_rst=0;delay(50);lcd_rst=1;delay(255);//等待復(fù)位lcd_cs1=0;lcd_cs2=0;lcd_cs3=0;wrile_com(0x3f);}void wrile_com(uchar com){ lcd_e=0; //lcd_rw=0;//讀寫選擇 寫lcd_rs=0;//數(shù)據(jù)命令 命令lcd_e=1; //P2=com;_nop_();lcd_e=0;delay(5);}void wrile_data(uchar dat){ lcd_e=0; //lcd_rw=0;//讀寫選擇 寫lcd_rs=1;//數(shù)據(jù)命令 命令lcd_e=1; //P2=dat;_nop_();lcd_e=0;delay(5);}void XYZ(uchar q1,q2,q3){ wrile_com(q1);//顯示起始行 wrile_com(q2);//頁面地址 wrile_com(q3);//列地址設(shè)置}void QPCZ(uchar TT,rg) //液晶屏 清屏操作{uchar qw,qe,er;lcd_cs1=0;lcd_cs2=0;lcd_cs3=0;er=0xb8; XYZ(0xc0,0xb8,0x40);for(qw=0;qw8;qw++){ wrile_com(er);//頁面地址for(qe=0;qe64;qe++){ wrile_data(TT);delay(rg); }wrile_com(er++);//頁面地址}}void delay(uchar d0){uchar d1,d2;for(d1=d0;d1>0;d1--)for(d2=110;d2>0;d2--);}
單片機(jī)相關(guān)文章:單片機(jī)教程
單片機(jī)相關(guān)文章:單片機(jī)視頻教程
單片機(jī)相關(guān)文章:單片機(jī)工作原理
評(píng)論