编译错误如下:
template.c(173): error C141: syntax error near ';', expected 'hdata'
template.c(206): error C141: syntax error near ';', expected 'hdata'
template.c(208): error C202: 'i': undefined identifier
template.c(209): error C202: 'i': undefined identifier
template.c(211): error C202: 'j': undefined identifier
代码如下:
//独立按键(加消抖)
#include<reg52.h>
#define uint unsigned int;
#define uchar unsigned char;
sbit LED1=P1^0;
sbit KEY1=P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
uchar disnum;
uchar code table_du[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, //数码管段选编码
0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
delay(uchar);
void main()
{
KEY1=1;
P0=0xfe;
wela=1;
wela=0;
while(1)
{
if(KEY1==0)
{
delay(10); //延时10ms
if(KEY1==0) //消除前沿抖动
{
LED1=0;
disnum++;
if(disnum==10)
disnum=0;
while(!KEY1); //按键松手检测
delay(10);
while(!KEY1); //消除后沿抖动
}
}
else
{
LED1=1;
P0=table_du[disnum];
dula=1;
dula=0;
}
}
}
delay(uchar x)
{
uchar i,j;
for(i=0;i<x;i++)
{
for(j=0;j<200;j++);
}
}
|