为什么实现不了变换呢,还有就是怎么控制P2=0x08,P2=0x04;因为只想用2.2;2.3,不影响其他口,该怎么改呢
单片机源程序如下:
#include<reg51.h>
sbit a=P3^3;
sbit b=P3^4;
sfr P2M0=0xf3;
sfr P2M1=0xff;
unsigned char code Tab[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char int_time;
unsigned char second;
void delay()
{
unsigned char i;
for(i=0;i<200;i++)
;
}
void DisplaySecond(unsigned char k)
{
P2=0x08;
P1=Tab[k%10];
delay();
P2=0x04;
P1=Tab[k/10];
delay();
}
void main()
{
if(a==0)
{while(1)
{
DisplaySecond(second=12);
}
}
if(b==0)
{while(1)
{
DisplaySecond(second=13);
}
}
}
|