|
#include <REG52.H>
#define uchar unsigned char
#define uint unsigned int
sbit k1=P3^4;
sbit duan=P2^6;
sbit wei=P2^7;
uint m=0;
void delay(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=112;j>0;j--);
}
void smg()
{
uint i;
i=m%10;
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
P0=tab[i];
duan=1;
duan=0;
P0=0xfe;
wei=1;
wei=0;
m++;
}
void main()
{
while(1)
{
if(k1==0)
{
delay(10);
if(k1==0)
{
while(k1!=0);
smg();
}
}
}
}
//错误代码
//按键控制.C(21): error C141: syntax error near 'unsigned'
//按键控制.C(21): error C141: syntax error near '}'
//按键控制.C(22): error C202: 'tab': undefined identifier
|
|