标题:
发一个LCD1602 英文“鸡年快乐”程序
[打印本页]
作者:
dpj555
时间:
2017-4-16 14:13
标题:
发一个LCD1602 英文“鸡年快乐”程序
很长时间没有贡献了,今天有时间发一个程序,供大家参考。
#include<reg51.h>
#include"lcd.h"
/*******************************************************************************
* 函 数 名 : Lcd1602_Delay1ms
* 函数功能 : 延时函数,延时1ms
* 输 入 : c
* 输 出 : 无
* 说 名 : 该函数是在12MHZ晶振下,12分频单片机的延时。
*******************************************************************************/
//--定义全局变量--//
unsigned char PuZh[27] = "Happy year of the rooster";
unsigned char CnCh[41] = "Global Chinese festival Spring Festival";
//--声明全局变量--//
void Delay10ms(unsigned int c); //误差 0us
/*******************************************************************************
* 函 数 名 : main
* 函数功能 : 主函数
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/n(void)
{
unsigned char i;
LcdInit();
//--写第一行--//
for(i=0; i<27; i++)
{
LcdWriteData(PuZh[i]);
}
//--写第二行
LcdWriteCom(0xC0); //设置坐标在第二行
for(i=0; i<41; i++)
{
LcdWriteData(CnCh[i]);
}
LcdWriteCom(0x07); //设置每写一次整屏右移
while(1)
{
LcdWriteCom(0xC0); //设置坐标在第二行
for(i=0; i<41; i++)
{
LcdWriteData(CnCh[i]);
Delay10ms(100);
}
}
}
/*******************************************************************************
* 函 数 名 : Delay10ms
* 函数功能 : 延时函数,延时10ms
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/
void Delay10ms(unsigned int c) //误差 0us
{
unsigned char a, b;
//--c已经在传递过来的时候已经赋值了,所以在for语句第一句就不用赋值了--//
for (;c>0;c--)
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1