|
楼主 |
发表于 2012-4-2 10:38:08
|
显示全部楼层
这是我写的程序,大家看看问题在哪里
#include"reg51.h"
sbit s17=P3^2; //按键
#define uint unsigned int
#define uchar unsigned char
void one();
void two();
void three();
void delay(uint time);
uchar c;
uchar k,temp;
void main()
{
uchar time;
while(1)
{
if(s17==0)
{
delay(20);
if(s17==0)
{
c++;
}
if(c==1)
{time=0;}
if(c==4)
{c=0;}
}
if(++time>=150)
{
switch(c)
{
case 1:
one();
break;
case 2:
two();
break;
case 3:
three();
break;
default :
break;
}
}
}
}
void delay(uint time)
{
uint i,j;
for(i=0;i<time;i++)
for(j=0;j<50;j++);
}
void one()
{
uchar code nu[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
for(k=0;k<8;k++)
{
P1=nu[k];
delay(1500);
}
}
void two()
{
uchar code num[7]={0x3f,0x9f,0xcf,0xe7,0xf3,0xf9,0xfc};
for(k=0;k<7;k++)
{
P1=num[k];
delay(1500);
}
}
void three()
{
uchar code numm[6]={0x1f,0x8f,0xc7,0xe3,0xf1,0xf8};
for(k=0;k<6;k++)
{
P1=numm[k];
delay(1500);
}
}
|
|