下载此文档

超声波小车舵机转动避障.doc


文档分类:IT计算机 | 页数:约7页 举报非法文档有奖
1/7
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/7 下载此文档
文档列表 文档介绍
/**************************************************************************** 硬件连接 ****************************************************************************/ #include<> #include<> #defineSevro_moto_pwmP2_7 //接舵机信号端输入PWM信号调节速度 #defineECHOP2_4 //超声波接口定义 #RIGP2_5 //超声波接口定义 #defineLeft_moto_go{P1_0=1,P1_1=0,P1_2=1,P1_3=0;}//左边两个电机向前走 #defineLeft_moto_back{P1_0=0,P1_1=1,P1_2=0,P1_3=1;} //左边两个电机向后转 #defineLeft_moto_Stop{P1_0=0,P1_1=0,P1_2=0,P1_3=0;}//左边两个电机停转 #defineRight_moto_go{P1_4=1,P1_5=0,P1_6=1,P1_7=0;} //右边两个电机向前走 #defineRight_moto_back{P1_4=0,P1_5=1,P1_6=0,P1_7=1;} //右边两个电机向前走 #defineRight_moto_Stop{P1_4=0,P1_5=0,P1_6=0,P1_7=0;} //右边两个电机停转 unsignedcharconstdiscode[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF,0xff/*-*/}; unsignedcharconstpositon[3]={0xfe,0xfd,0xfb}; unsignedchardisbuff[4] ={0,0,0,0,};unsignedcharposit=0; unsignedcharpwm_val_left=0;//变量定义 unsignedcharpush_val_left=14;//舵机归中,产生约,=0; unsignedlongS1=0; unsignedlongS2=0; unsignedlongS3=0; unsignedlongS4=0; unsignedinttime=0; //时间变量 unsignedinttimer=0; //延时基准变量 unsignedchartimer1=0; //扫描时间变量/************************************************************************/ voiddelay(unsignedintk) //延时函数{unsignedintx,y; for(x=0;x<k;x++) for(y=0;y<2000;y++);}/************************************************************************/voidDisplay(void) //扫描数码管 { if(posit==0) {P

超声波小车舵机转动避障 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数7
  • 收藏数0 收藏
  • 顶次数0
  • 上传人rdwiirh
  • 文件大小26 KB
  • 时间2020-09-14