Description: #include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code duma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f, //共阴的数码管段选.将值送给P2口
0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x40,0x80,0x00} //数值‘ 0-F - 熄灭
uchar code wema[]={0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7} //片选,1-8个数码管
void delay(uchar x)
{
uchar a,b
for(a=x a>0 a--)
for(b=50 b>0 b--)
}
void main()
{
uchar i
while(1)
{
for(i=0 i<8 i++)
{
P2=duma[i+1] //取值从 1 开始。
P1=wema[i]
delay(20)
}
}
}
To Search:
File list (Check if you may need any files):
LED02.c