#include<stdio.h>
#include<intrins.h>
#define uchar unsigned char;
#define uint unsigned int;
sbit dula=P2^6;
sbit wela=P2^7;
sbit adwr=P3^6;
sbit adrd=P3^7;
uchar a,flag1,flag2,num1,flag_on,ad_val;
float ad_vo;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0};
void delays(uint x)
{
uint c,b;
for(c=x;c>0;c--)
for(b=110;b>0;b--);
}
void init()
{
TMOD=0x21;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=0xfd;
TL1=0xfd;
TR1=1;
ET0=1;
SM0=0;
SM0=1;
REN=1;
EA=1;
ES=1;
}
void display(uchar value)
{
uchar bai,shi,ge;
bai=value/100;
shi=value%100/10;
ge=value%10;
dula=1;
P0=table[bai];
dula=0;
P0=0xff;
wela=1;
P0=0xf7;
wela=0;
delays(5);
dula=1;
P0=table[shi];
dula=0;
P0=0xff;
wela=1;
P0=0xef;
wela=0;
delays(5);
dula=1;
P0=table[ge];
dula=0;
P0=0xff;
wela=1;
P0=0xdf;
wela=0;
delays(5);
}
uchar get_ad()
{
uchar adval;
adwr=1;
_nop_();
adwr=0;
_nop_();
adwr=1;
P1=0xff;
adrd=1;
_nop_();
adrd=0;
_nop_();
adval=P1;
adrd=1;
return adval;
}
void main()
{
init();
wela=1;
P0=0xfe;
wela=0;
while(1)
{
if(flag2==1)
{
flag2=0;
ES=0;
TI=1;
switch(flag_on)
{
case 0:puts("Turn on ad!
");
TR0=1;
break;
case 1:puts("Turn off ad!
");
TR0=0;
break;
case 2:puts("ERROR!
");
break;
}
while(!TI);
TI=0;
ES=1;
}
if(flag1==1)
{
flag1=0;
ad_val=get_ad();
ad_vo=(float)ad_val*5.0/256.0;
ES=0;
TI=1;
printf("The volag is %fV
",ad_vo);
while(!TI);
TI=0;
ES=1;
}
display(ad_val);
}
LESSON1-4.C(18): error C141: syntax error near ';'
LESSON1-4.C(20): error C202: 'c': undefined identifier
LESSON1-4.C(21): error C202: 'c': undefined identifier
LESSON1-4.C(22): error C202: 'b': undefined identifier
LESSON1-4.C(42): error C141: syntax error near ';'
LESSON1-4.C(44): error C202: 'bai': undefined identifier
LESSON1-4.C(45): error C202: 'bai': undefined identifier
LESSON1-4.C(46): error C202: 'shi': undefined identifier
LESSON1-4.C(47): error C202: 'ge': undefined identifier
LESSON1-4.C(50): error C202: 'bai': undefined identifier
LESSON1-4.C(59): error C202: 'shi': undefined identifier
LESSON1-4.C(68): error C202: 'ge': undefined identifier
LESSON1-4.C(78): error C202: 'adval': undefined identifier
LESSON1-4.C(89): error C202: 'adval': undefined identifier
LESSON1-4.C(91): error C202: 'adval': undefined identifier
lesson1-4.c - 15 Error(s), 0 Warning(s).
为什么会出现这个错误,我找不到啊,求指教
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>