|
51hei圖片_20200502155701.png (34.6 KB, 下載次數(shù): 33)
下載附件
2020-5-2 15:57 上傳
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar temp1,temp2,signal1,signal2;
void delay_1ms(uint d)
{
uint i;
while(d--)
for(i=0;i<75;i++);
}
void main0()
{
EA=1;
ET1=1;
TR1=1;
TMOD=0x01;
TH1=-(1000/256);
TL1=-(1000%256);
temp1=P0;
signal1=temp1&0xff;
if(signal1==0xff)
{
void motor_run() // ??????
{
P1=0x53;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
/* ENA=1;
OUT1=0;
OUT2=1;
delay_1ms(800);
OUT2=0;
delay_1ms(200);
ENB=1;
OUT4=0;
OUT3=1;
delay_1ms(800);
OUT3=0;
delay_1ms(200);
*/
}
void motor_left() //???
{
P1=0x50;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_right() //???
{
P1=0x03;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_big_right() //?????
{
P1=0x33;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_big_left() //?????
{
P1=0x55;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_stop() //?????
{
P1=0x00;
}
void motor_back() //???????
{
P1=0x35;
}
void main1()
{
EA=1;
ET1=1;
TR1=1;
TMOD=0x01;
TH1=-(1000/256);
TL1=-(1000%256);
while(1)
{
temp2=P2;
signal2=temp2&0xff; //????????????
switch(signal2)
{
case 0xff: //?????
motor_run();
break;
case 0xfb: //????
motor_left();
break;
case 0xfd: //???
case 0xf9:
motor_big_left();
break;
case 0xfe: //???????
case 0xfc:
motor_big_left();
delay_1ms(10);
break;
case 0xef: //????
motor_right();
break;
case 0xdf: //???
case 0xcf:
motor_big_right();
break;
case 0xbf: //???????
case 0x9f:
motor_big_right();
delay_1ms(10);
break;
case 0xc9: //?м??????????????????
case 0x88: //???д???????????????
motor_back();
delay_1ms(200);
motor_stop();
default:
break;
}
}
}
}
else
{
void motor_run1 () // ?????????
{
P1=0x35;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
/* ENA=1;
OUT1=1;
OUT2=0;
delay_1ms(800);
OUT2=1;
delay_1ms(200);
ENB=1;
OUT4=1;
OUT3=0;
delay_1ms(800);
OUT3=1;
delay_1ms(200);
*/
}
void motor_left1() //???
{
P1=0x30;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_right1() //???
{
P1=0x05;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_big_right1() //?????
{
P1=0x55;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_big_left1() //?????
{
P1=0x33;
delay_1ms(150);
P1=0x00;
delay_1ms(20);
}
void motor_stop1() //?????
{
P1=0x00;
}
void motor_back1() //???????
{
P1=0x53;
}
void main2()
{
EA=1;
ET1=1;
TR1=1;
TMOD=0x01;
TH1=-(1000/256);
TL1=-(1000%256);
while(1)
{
temp2=P2;
signal2=temp2&0xff; //????????????
switch(signal2)
{
case 0xff: //?????
motor_run1();
break;
case 0xfb: //????
motor_left1();
break;
case 0xfd: //???
case 0xf9:
motor_big_left1();
break;
case 0xfe: //???????
case 0xfc:
motor_big_left1();
delay_1ms(10);
break;
case 0xef: //????
motor_right1();
break;
case 0xdf: //???
case 0xcf:
motor_big_right1();
break;
case 0xbf: //???????
case 0x9f:
motor_big_right1();
delay_1ms(10);
break;
case 0xc9: //?м??????????????????
case 0x88: //???д???????????????
motor_back1();
delay_1ms(200);
motor_stop1();
default:
break;
}
}
}
}
}
這幾行顯示語法錯(cuò)誤,但是后面程序中有相同形式的語句,是正確的,這幾個(gè)錯(cuò)誤要怎么改,上面是完整的程序
|
|