#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
//uchar code dis_code[]={0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9}; //共阳数码管段码表
//共阴字形码表【实验】数码管实验时,一定要将点阵模块跳针放到VCC上!!!
uchar led[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71}; //共阴字形码表【实验】
void delay(uint t) //延时函数
{
uchar i;
while(t--) for(i=0;i<200;i++);
}
void main(void)
{
uchar i,j;
while(1)
{
for(i=0;i<4;i++)
{
j=1<<i;
P2=led[i];
P1=~j; //P2口输出位控码
delay(3); //延时,控制每位显示的时间,=180:流水显示;=1:连续显示
P1=0xff;
delay(1);
}
}
}