標籤:
看了一下居然沒有液晶顯示屏。。算了 有錢了再買 先扔個程式
/******************************************************************************** 實 驗 名 : LCD1602實驗* 使用的IO : LCD使用P0 * 實驗效果 : 在液晶屏上顯示 love* 注 意 :*******************************************************************************/#include <reg52.h>#include <intrins.h>#define GPIO_LED P2#define GPIO_LCD P0#define GPIO_KEY P1#define uint unsigned int#define uchar unsigned charsbit LCDE=P2^7;sbit RW=P2^5;sbit RS=P2^6;uchar code DIG_CODE[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};uchar My_code[]="love";void Delay10ms();void LcdInit();void LcdWriteCom(uchar com);void LcdWriteData(uchar dat);void main(){uchar i;LcdInit();for(i=0;i<4;i++)LcdWriteData(My_code[i]);while(1){}}void Delay10ms(){ uchar i=38,j=130; while(i--) while(j--);}void LcdWriteCom(uchar com)//讀命令{RS=0;RW=0;GPIO_LCD=com;LCDE=1;Delay10ms();LCDE=0;}void LcdWriteData(uchar dat) //讀資料{RS=1;RW=0;GPIO_LCD=dat;LCDE=1;Delay10ms();LCDE=0;}void LcdInit() //初始化{LcdWriteCom(0x38);LcdWriteCom(0x0c);LcdWriteCom(0x06);LcdWriteCom(0x01);LcdWriteCom(0x80);}
51單片機第六彈---LCD液晶顯示模組