#include<reg51.h>
unsigned char code table[]={//共阴段码
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char led_mod[]={0xfe,0xfd,0xfb,0xf7};//位码
void delay(unsigned int time)
{
unsigned int j;
{
for(j=0;j<time;j++);
}
}
void main()
{
unsigned char i;
while(1)
{
for(i=0;i<4;i++)
{
P2=0x00;//消隐
P3=led_mod;//送位码
P2=table;//送段码
delay(240);//延时2ms
}
}
}
|