大佬帮忙看看还能咋改
#include <REG52.H>
void de10();
void de();
void change_time();
sbit led=P2^5;
long int s2,s1;
int i=0;
sbit p22=P2^2;
sbit p23=P2^3;
sbit p24=P2^4;
sbit k1=P3^1;
sbit k2=P3^0;
sbit k3=P3^2;
sbit k4=P3^3;
char num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void change_time(){
// she ding shi jain
static int sx=1;
if(k1==0){
de10();
if(k1==0&&sx==1){
sx=2;
}
else if(k1==0&&sx==2){
sx=1;
}
while(!k1);
}
if(k2==0){
if(k2==0){
while(!k2);
switch(sx){
case 1:s1++;break;
case 2:s2++;break;
}
}
// while(!k1);
}
if(k3==0){
if(k3==0){
while(!k3);
switch(sx){
case 1:s1--;break;
case 2:s2--;break;
}
}
}
if(s1==10&&s2!=9){
s1=0;
s2++;
}
if(s1==-1&&s2!=0){
s1=9;
s2--;
}
if(s1>=9&&s2>=9){
s1=9;s2=9;
}
if(s1<=0&&s2<=0){
s1=0;s2=0;
}
if(s2>=9){
s2=9;
}
}
void de10() //@12.000MHz
{
unsigned char i, j;
i = 117;
j = 184;
do
{
while (--j);
} while (--i);
}
void de() //@12.000MHz
{
unsigned char i, j;
i = 3;
j = 82;
do
{
while (--j);
} while (--i);
}
void dakai(){
EA=1;
ET0=1;
TMOD|=0X01;
TH0=0Xd8;
TL0=0Xf0;
TR0=1;
}
/
void main(){
while(1){
while(k4)
{
change_time();
P0=num[s1];
p22=0;
p23=0;
p24=0;
de();
P0=num[s2];
p22=1;
p23=0;
p24=0;
de();
}
dakai();
}
}
///
void inti0() interrupt 1{
TH0=0xd8;
TL0=0xf0;
i++ ;
//xiang xia jian
if(i==166){
s1=s1-1;
i=1;
}
}
|