|
很長時(shí)間沒有貢獻(xiàn)了,今天有時(shí)間發(fā)一個程序,供大家參考。
#include<reg51.h>
#include"lcd.h"
/*******************************************************************************
* 函 數(shù) 名 : Lcd1602_Delay1ms
* 函數(shù)功能 : 延時(shí)函數(shù),延時(shí)1ms
* 輸 入 : c
* 輸 出 : 無
* 說 名 : 該函數(shù)是在12MHZ晶振下,12分頻單片機(jī)的延時(shí)。
*******************************************************************************/
//--定義全局變量--//
unsigned char PuZh[27] = "Happy year of the rooster";
unsigned char CnCh[41] = "Global Chinese festival Spring Festival";
//--聲明全局變量--//
void Delay10ms(unsigned int c); //誤差 0us
/*******************************************************************************
* 函 數(shù) 名 : main
* 函數(shù)功能 : 主函數(shù)
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/n(void)
{
unsigned char i;
LcdInit();
//--寫第一行--//
for(i=0; i<27; i++)
{
LcdWriteData(PuZh[i]);
}
//--寫第二行
LcdWriteCom(0xC0); //設(shè)置坐標(biāo)在第二行
for(i=0; i<41; i++)
{
LcdWriteData(CnCh[i]);
}
LcdWriteCom(0x07); //設(shè)置每寫一次整屏右移
while(1)
{
LcdWriteCom(0xC0); //設(shè)置坐標(biāo)在第二行
for(i=0; i<41; i++)
{
LcdWriteData(CnCh[i]);
Delay10ms(100);
}
}
}
/*******************************************************************************
* 函 數(shù) 名 : Delay10ms
* 函數(shù)功能 : 延時(shí)函數(shù),延時(shí)10ms
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/
void Delay10ms(unsigned int c) //誤差 0us
{
unsigned char a, b;
//--c已經(jīng)在傳遞過來的時(shí)候已經(jīng)賦值了,所以在for語句第一句就不用賦值了--//
for (;c>0;c--)
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
|
評分
-
查看全部評分
|