武术擂台机器人

武术擂台机器人

stm32f103vet6 + oled + 得科电机 + 驼峰胎 + 红外测距传感器

接线

传感器

Left00接PD7

Right00接PD2

Left01接PA4

Right01接PA3

Left02接PA6

Right02接PA1

Left03接PA7

Right03接PA0

Left04接PC4

Right04接PC3

Left05接PC5

Right05接PC2

Behind00接PC0

驱动板

左侧:

pwml1接PA9,pwml2接PA8,EN不接,两个GND中,只需将其中任意一个GND与主控板GND相连

右侧:

pwml1接PA11,pwml2接PA10,EN不接,两个GND中,只需将其中任意一个GND与主控板GND相连

平避障 逆时针 距离变小 顺时针 距离变大 棕正蓝负黑信号

红外测距 红正黑负黄信号

左转 左后右前 右转 左前右后

避障序号

主要程序

image-20221005130100939

void bianyuanshibie() 
{
	//int b;
if(ltsbflag==0)
{

	
	
if(hui3==1&&hui4==1&&hui1==1&&hui2==1&&mm1==1&&mm2==1)  stop();
//else ahead(300);
else if(((temp1>1700&&temp7>1700)||(temp4>1700&&temp6>1700)||(temp1>1700&&(temp4>1700||temp6>1700))||(temp7>1700&&(temp4>1700||temp6>1700))||(temp3>1700&&temp4>1700&&temp9>1700)||(temp5>1700&&temp6>1700&&temp8>1700))&&ot<3)
	{
		
			//ltsbflag=1;
					ot++;
			
	}
//else if(backflag==1&&temp1>1600) 
//{
	//if(temp1<1600) backflag=0;
	//else  stop();
//}
	
else	
{

		if(mm1==1||mm2==1||hui1==1||hui2==1)

	
	
	
{

		
	 if( temp1>1600  )    // two sensor front find enemy 2  
			{		
					
					
					
			  
					if ((hui1==1||hui2==1)) 
				{
					if(temp7>1600) {left(800);x0++;}
					else	
					{
							//back(600,600);
						//if(hui1==0&&hui2==0)
						back(500,500);
						
						f++;
					}
					
				}
				
					else 
					{
						if(backflag==0)
						{
						allahead(500);
						allaheadflag=1;
						}
					}
					
				
			}
			else if(temp7>1600)  
			{
					left(800);
					x5++;
			}
		else if(  temp3>1600||temp4>1600||mm3==0||temp9>1600) //one sensor  right and right back  find enemy  and right back   2   temp3>1500 || temp4>1500  ||
			{
				
					if(temp3>1600)  right(600);
				else if(temp9>1600) right(800);
					else right(700);
				
			
			}
		else if( temp6>1600||temp5>1600||mm4==0||temp8>1600 )  //onr sensor left and left back find enemy 2    temp5>1500 ||temp6>1500 ||
			{
			
					if(temp5>1600)	left(600);
				else if(temp8>1600) left(800);
					else left(700);
				//x1++;
				
			}
		//else if(temp7>1700)  {left(720);x5++;}

	
		else	if(hui3==1&&hui4==1)
	{
				if(mm1==1||mm2==1||hui1==1||hui2==1)
		{
			 
				diaotou(500);x2++;
			
		}
				else
		{
		ahead(450);
		//ltsbflag=0;
		}
	}
		else 
	{
				if((hui1==1||hui2==1)&&(mm1==1||mm2==1)) {back(500,500);f++;}
				else 
				diaotou(500);
				x3++;
	}
	
	

	

}


else if( temp1>1600  )    // two sensor front find enemy 2  
			{		
					
					
							if(temp7>1600)  {diaotou(500);x4++;}
							else           
							{ 
						     if(backflag==0)
										{
											allahead(600);
											allaheadflag=1;
										}
							}
					
				
			}
else if(temp7>1600)  {left(900);x7++;}


else if(  temp3>1600||temp4>1600||mm3==0||temp9>1600) //one sensor  right and right back  find enemy  and right back   2   temp3>1500 || temp4>1500  ||
			{
					if(temp3>1600)  right(600);
				else if(temp9>1600) right(800);
					else right(700);
				
			}
else if( temp6>1600||temp5>1600||mm4==0||temp8>1600 )  //onr sensor left and left back find enemy 2    temp5>1500 ||temp6>1500 ||
			{
					
					if(temp5>1600)	left(600);
				else if(temp8>1600) left(800);
					else left(700);
				x6++;
			}

//else if(temp7>2000)  {left(720);x7++;}
else ahead(450);
			
}
		
}

duojiz(900);
duojiy(900);

//if(j>0&&f>0) 
	//{
 //   backflag=1;
//	}  
//	else backflag=0;
if(allaheadflag==1) 
{
	j+=4;
	if(j>300) j=300;
}
else j=0;

if(ot>2) 	{ltsbflag=1;}

}

实车及源码程序

image-20221005130142933

github程序源码

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-特立独行的猪-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值