用51单片机并行口设计显示一个数码的电路,使数码管循环显示“0”~“F”。

如题所述

这是共阳极的数码管,至于你要显示0~F这个在编程实现

温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-05-20

#include <reg52.h>

#include <intrins.h>

#define uchar unsigned char

#define uint unsigned int

uchar code DSY_CODE[]=

{

  0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff

};

void DelayMS(uint x)

{

  uchar t;

while(x--)

for(t=120;t>0;t--);

}

void main()

{

  uchar i=0;

P0=0x00;

while(1)

{

  P0=~DSY_CODE[i];

i=(i+1)%16;/*显示0-f*/

DelayMS(400);

}

}

相似回答