數位管循環點亮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);
}
}