建設(shè)主管部門門戶網(wǎng)站鄭州網(wǎng)站排名優(yōu)化公司
/*-----------------------------------------------
? 內(nèi)容:數(shù)碼管使用動(dòng)態(tài)掃描顯示,所以可以同時(shí)看到數(shù)碼管同時(shí)顯示數(shù)字或者字符。
------------------------------------------------*/
#include<reg52.h> //包含頭文件,一般情況不需要改動(dòng),頭文件包含特殊功能寄存器的定義
unsigned char const dofly[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};// 顯示段碼值01234567
unsigned char code ?seg[]={0,1,2,3,4,5,6,7};//分別對(duì)應(yīng)相應(yīng)的數(shù)碼管點(diǎn)亮,即位碼
/*------------------------------------------------
? ? ? ? ? ? ? ? ? ? 延時(shí)子程序
------------------------------------------------*/
void delay(unsigned int cnt)
{
?while(--cnt);
}
/*------------------------------------------------
? ? ? ? ? ? ? ? ? ? 主函數(shù)
------------------------------------------------*/
main()
{
?unsigned char i;
?while(1)
? ? ? {
?
? ? ? ?P0=dofly[i];//取顯示數(shù)據(jù),段碼
?? ? ? P2=seg[i]; ?//取位碼
?? ? ? delay(20000); //掃描間隙延時(shí),時(shí)間太長會(huì)閃爍,太短會(huì)造成重影,這里使用長時(shí)間方便了解顯示原理
?? ? ? i++;
?? ? ? if(8==i) ? ?//檢測8位掃描完全?
?? ? ? ? i=0;
? ? ? }
}