标签:
看了一下居然没有液晶显示屏。。算了 有钱了再买 先扔个程序
/******************************************************************************* * 实 验 名 : 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 char sbit 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); }
标签:
原文地址:http://blog.csdn.net/qq_16255321/article/details/42781619