⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 four.h

📁 该设计采用单片机AT89S52作为电动车的检测和控制核心(控制器),实现电动车的路线识别、跷跷板平衡检测等功能。同时通过反射式光电传感器识别与地面顔色有较大差别的导引线
💻 H
字号:
void Basic3()
{
 uint t,spe,s;
 uchar num=0,m,n;
 uchar line,setspeed=1;
 bit sign=0;  //走过白线
 right=0;
 left=0;
 time=12;
 a=1;
 b=0;
 line=0;
 Cls();
 second=0;
 num=0;
 Icount=0;
 s=0;
 while(1)
  {
	  num++	;
	  if(num>=50)
	   {
		spe=Icount*10/13;s+=spe*24/10;spe=spe*24/10;
		if(Icount<10 && time<20) time++;
		if(Icount>10 && time>0) time--;
		num=0;
		Icount=0;
	   }
	  if(speed>setspeed && time>0) {time--;}
	  if(speed>setspeed && time==0)	{TR0=0;advance=0;back=1;for(t=0;t<3000;t++);back=0;TR0=1; }
	  if(!find_f)
	   {
	    if(find_l && !find_r) {right=0;left=1;}
	    if(find_r && !find_l){ left=0;right=1;}
	   }
	 else 
	   {
	    left=0;
	    right=0;
	    if(!find_l && !find_r) sign=0;
	   }
	 if(find_l && find_r)
	  {
	    if(!sign){line++;sign=1;}
	  }
	
	 	  
	disdat[3]=spe/10;
	disdat[2]=(spe%100)/10;
	disdat[1]=(spe%1000)/100;
	disdat[0]=spe/1000;
	disdat[7]=s/10;
	disdat[6]=(s%100)/10;
	disdat[5]=(s%1000)/100;
	disdat[4]=s/1000;
	display(0x22);
	if(line==0x02)
	 {
	  
	  a=0;
	  time=18;
	  b=1;
	  for(t=0;t<5000;t++);
	  time=5; 
	  second=0;
	  while(second<250)
	   {
		m=second/50;
		disdat[7]=5-m;
		display(0);
		n=second+30;
		beep=0;
		while(n>second);
		beep=1;
		while(m==second/50);
	   }
	  break;	 
	 }

	while(!tf);
	tf=0;
  }
while(1);
   a=0;
   b=1;
   right=0;
   left=0;
   second=0;
   num=0;
   Icount=0;
 while(1)
  {
   	 num++	;
	  if(num>=50)
	   {
		if(Icount<3 && time<20) time++;
		if(Icount>3 && time>0) time--;
		num=0;
		Icount=0;
	   }
	if(speed>setspeed && time>0) {time--;}
   if(speed>setspeed && time==0)	{TR0=0;back=0;advance=1;for(t=0;t<3000;t++);advance=0;TR0=1; }
   if(!find_l && !find_r) sign=0;
	  
	 if(find_l && find_r)
	  {
	    if(!sign){line++;sign=1;}
	  }
	if(line==3)
	  {
	   b=0;
	   a=1;
	   time=20;
	   for(t=0;t<5000;t++);
	   time=5;
	   b=0;
	   a=1;
	   
	   while(1);
	   }
	m=second/50;
	disdat[7]=m%10;
	disdat[6]=m/10;
	display(0);	
	while(!tf);
	tf=0;
/*  while(1)
    {
	  if(find_r && find_l)b=0;
	}	*/
  }
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -