|
很長時間沒有貢獻了,今天有時間發一個程序,供大家參考。
#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--);
}
}
}
|
評分
-
查看全部評分
|