#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint z);
uchar code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//显示0~F的值
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4; //138译码器
void main()
{
LSA=0;
LSB=0;
LSC=0; //控制138译码器的Y0输出低电平
while(1)
{
uchar m;
for(m=0;m<16;m++)
{
P0=smgduan[m];
delay(1000);//1s
P0=0x00; //消隐
}
}
}
void delay(uint z) //延时函数
{
uint x,y;
for(x=z;x>0;x–)
for(y=100;y>0;y–);
}