#include#define uint unsigned int#define uchar unsigned charsbit port_1=P3^5;sbit port_2=P3^4;sbit port_3=P3^1;sbit port_4=P3^0;sbit en_1=P3^2;sbit en_2=P3^3;sbit infrared1 = P0^2;sbit infrared2 = P0^3;sbit infrared3 = P0^4;uchar infrared,num,left,right;void init(){TMOD=0x01;TH0=(65536-1000)/256;TR0=(65536-1000)%256;EA=1;ET0=1;TR0=1;en_1 = 1;en_2 = 1;}void motor(uchar pesition){if(pesition == 0){port_1=0; //左电机port_2=1;port_3=0; //右电机port_4=1;}if(pesition == 1){port_1=0; //左电机port_2=1;port_3=1; //右电机port_4=0;}if(pesition == 2){port_1=1; //左电机port_2=0;port_3=0; //右电机port_4=1;} if(pesition == 3){port_1=1; //左电机port_2=0;port_3=1; //右电机port_4=0;} if(pesition == 4){port_1=0; //左电机port_2=0;port_3=0; //右电机port_4=0;}}void infraredscan(){if(
infrared1 &&
infrared2 &&
infrared3){motor(4);}if(