#include"reg52.h"
#define uint unsigned int
#define uchar unsigned char
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
void delay(uint);
void main()
{
uint i,j;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
while(1)
{
for(i=1;i<9;i++)
{
switch(i)
{
case 1 : a=0;b=0;c=0;break;
case 2 : a=1;b=0;c=0;break;
case 3 : a=0;b=1;c=0;break;
case 4 : a=1;b=1;c=0;break;
case 5 : a=0;b=0;c=1;break;
case 6 : a=1;b=0;c=1;break;
case 7 : a=0;b=1;c=1;break;
case 8 : a=1;b=1;c=1;break;
}
for(j=0;j<16;j++)
{
P0=table[j];
delay(500);
}
}
}
}
void delay(uint w)
{
uint i,j;
for(i=w;i>0;i--)
for(j=110;j>0;j--);
}
|