数码管循环点亮0到9)
-
-
- 要求描述:
- 仿真图
- 代码
-
要求描述:
选用AT89C51单片机,绿色7段共阴极数码管,使用C语言实现
仿真图
代码
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]=
{
0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f
};
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%10;
i++;
DelayMS(1000);
}
}