0428 数码管循环显示

一、功能描述

数码管循环显示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; //ÏûÒþ

switch(pos) //Ñ¡ÔñÊýÂë¹ÜλÖÃ

{

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; //Êä³öÊýÂë¹ÜÏÔʾµÄÄÚÈÝ

}

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;

}

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一 功能描述 数码管循环显示1000-3000 数码管显示数字0,显示带小数点的 7 二 程序 #include ...
    808bass_40f3阅读 197评论 0 0
  • 一 功能显示 数码管循环显示1000-3000 二,程序 #include "reg52.h" sbit C1 =...
    Jinguji阅读 159评论 0 0
  • 代码 /******************СÃÛ·äÀÏʦµÄ51µ¥Æ¬»ú¿ª·¢ÏîÄ¿°¸Àý***...
    lLcoM阅读 81评论 0 0
  • 记录一下 用到的软件 1 Keil uVision5 (把源代码编译成HEX文件) 2 stc-isp-15xx-...
    芳欣美阅读 2,321评论 0 0
  • 引入 在业务开发中,我们常把数据持久化到数据库中。如果需要读取这些数据,除了直接从数据库中读取外,为了减轻数据库的...
    Sam_L阅读 520评论 0 1