1、自动循迹小车程序(51)#define P_IOA_Data (volatile unsigned int *)0x7000#define P_IOA_Dir (volatile unsigned int *)0x7002#define P_IOA_Attrib (volatile unsigned int *)0x7003unsigned int scan();/检测黑线函数定声明unsigned int num=0;void delay();void init_1()/输入初始化P_IOA_Dir=0x00f0;P_IOA_Attrib=0x00f0;P_IOA_Data=0x000f;/
2、void init_2()/输出初始化/P_IOA_Dir=1;/P_IOA_Attrib=1;/P_IOA_Data=0;/void main()while(1)void init_1();num=scan();/void init_2();switch(num)case 1:while(1)P_IOA_Data=0x9f;delay(500);/ if(P_IOA_Data=1)/传感器返回 1,则终止转弯,下同break;case 2:while(1)P_IOA_Data=0x9f;delay(500);break;case 4:while(1)P_IOA_Data=0x6f;delay
3、(500);break;case 5:while(1)P_IOA_Data=0x6f;delay(500);break;case 0:while(1)P_IOA_Data=0x5f;delay(500);break;P_IOA_Data=0x5f;/直走delay(500);void delay(uint z)uint x,y;for(x=z;x0;x-)for(y=110;y0;y-); unsigned int scan()if(P_IOA_Data=0xfe)num=1;return num;if(line_2=0xfd)num=2;return num; if(line_4=0xfb)num=4;return num; if(line_5=0xf7)num=5;return num;return 0;