资源描述:
《lcd1602与单片机》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、液晶1602的汉字显示运行环境:STC89C52单片机12M晶振程序说明:***************************************************************/#include#include#defineucharunsignedchar#defineuintunsignedintsbite=P2^7;sbitrs=P2^6;sbitrw=P2^5;sbitLCD7=P0^7;sbitLCD6=P0^6;sbitLCD5=P0^5;sbitLCD4=P0^4;ucharb
2、datalcdbuff;uintloop,x=30;sbitlcdbuff0=lcdbuff^0;sbitlcdbuff1=lcdbuff^1;sbitlcdbuff2=lcdbuff^2;sbitlcdbuff3=lcdbuff^3;sbitlcdbuff4=lcdbuff^4;sbitlcdbuff5=lcdbuff^5;sbitlcdbuff6=lcdbuff^6;sbitlcdbuff7=lcdbuff^7;/**************字模*****************/unsignedcharcodetab[]={/*--文字:中--*/
3、/*--宋体12;此字体下对应的点阵为:宽x高=16x16--*/0x01,0x01,0x21,0x3F,0x21,0x21,0x21,0x21,0x21,0x3F,0x21,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x08,0xFC,0x08,0x08,0x08,0x08,0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,/*--文字:国--*//*--宋体12;此字体下对应的点阵为:宽x高=16x16--*/0x00,0x7F,0x40,0x5F,0x41,0x41,0x41,0x4F,0x
4、41,0x41,0x41,0x5F,0x40,0x40,0x7F,0x40,0x00,0xFC,0x04,0xF4,0x04,0x04,0x04,0xE4,0x44,0x24,0x24,0xF4,0x04,0x04,0xFC,0x04,/*--文字:电--*//*--宋体12;此字体下对应的点阵为:宽x高=16x16--*/0x01,0x01,0x01,0x3F,0x21,0x21,0x3F,0x21,0x21,0x21,0x3F,0x21,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0xF8,0x08,0x08,0xF8,0x
5、08,0x08,0x08,0xF8,0x08,0x02,0x02,0xFE,0x00,/*--文字:子--*//*--宋体12;此字体下对应的点阵为:宽x高=16x16--*/0x00,0x3F,0x00,0x00,0x00,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x01,0x01,0x05,0x02,0x00,0xF0,0x20,0x40,0x80,0x00,0x00,0x04,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--文字:网--*//*--宋体12;此字体下对应的点阵为:
6、宽x高=16x16--*/0x00,0x7F,0x40,0x41,0x51,0x4A,0x44,0x44,0x4A,0x4A,0x51,0x61,0x40,0x40,0x40,0x00,0x00,0xFC,0x04,0x04,0x14,0x9C,0x54,0x24,0x24,0x54,0x94,0x04,0x04,0x1C,0x08,0x00,};/************函数声明***************/voidr_BF();voidw_cdata(void);voidw_com(ucharcom);voidw_sting(ucharstring
7、);voidinit_lcd();voidcg_w();voidw_word(ucharword);voiddelay(uintxms);/************主函数*************/voidmain(){init_lcd();while(1){w_com(0x01);//清屏loop=0;cg_w();w_com(0x80);w_word(0x00);w_word(0x00+2);w_word(0x00+4);w_com(0x80+0x40);w_word(0x00+1);w_word(0x00+3);w_word(0x00+5);del
8、ay(x);//********************************