|
|
楼主 |
发表于 2014-10-31 19:26:39
|
显示全部楼层
#include <reg51.h>
sbit ins1=P1^7;
unsigned char code segment1[]={0xff,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80};//段码表
unsigned char code segment2[]={0xff,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7};//编码表
void delay(void)
{
unsigned int i;
for(i=0;i<500;i++)
;
}
void main()
{
unsigned char x=0;
while (1)
{
P0=segment1[x];
P1=segment2[x];
if(ins1==0)
{
x++;
delay();
if(x==9)x=0;
delay();
while(ins1==0);
delay();
}
}
} |
| |