0428 數(shù)碼管循環(huán)顯示

一、功能描述

數(shù)碼管循環(huán)顯示1000-3000

二、功能展示


三、流程圖


四、程序

#include "reg52.h"

sbit C1 = P2^7;

sbit C2 = P2^6;

sbit C3 = P2^5;

sbit C4 = P2^4;

unsigned char SMGNoDot_CA[10] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};

unsigned int count = 1000;

void DelaySMG(unsigned int t)

{

while(t--);

}

void DisPlaySMG_Bit(unsigned char pos, unsigned char dat)

{

P0 = 0xff; //??òt

switch(pos) //????êy??1ü????

{

case 1:

C1 = 1; C2 = 0; C3 = 0; C4 = 0;

break;

case 2:

C1 = 0; C2 = 1; C3 = 0; C4 = 0;

break;

case 3:

C1 = 0; C2 = 0; C3 = 1; C4 = 0;

break;

case 4:

C1 = 0; C2 = 0; C3 = 0; C4 = 1;

break;

}

P0 = dat; //ê?3?êy??1ü??ê?μ??úèY

}

void DisPlaySMG_4Bit(unsigned int dat)

{

DisPlaySMG_Bit(1, SMGNoDot_CA[dat / 1000]); //?§??

DelaySMG(100);

DisPlaySMG_Bit(2, SMGNoDot_CA[(dat % 1000) / 100]); //°ù??

DelaySMG(100);

DisPlaySMG_Bit(3, SMGNoDot_CA[(dat % 100) / 10]); //ê???

DelaySMG(100);

DisPlaySMG_Bit(4, SMGNoDot_CA[(dat % 10)]); //????

DelaySMG(100);

}

void DisPlaySMG_zero_nine()

{

char i;

C1 = 1;

C2 = 1;

C3 = 1;

C4 = 1;

for(i = 0; i < 10; i++)

{

P0 = SMGNoDot_CA[i];

DelaySMG(40000);

}

}

void Delay(unsigned int t)

{

while(t--)

{

DisPlaySMG_4Bit(count);

}

}

void main()

{

DisPlaySMG_zero_nine();

while(1)

{

DisPlaySMG_4Bit(count);

Delay(1);

count++;

if(count == 3000)

{

count = 1000;

}

}

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容