智能机器人报告(编辑修改稿)内容摘要:

有检测到黑线吗 直走 Y N 4 灯检测到黑线 3 灯检测到黑线 N Y 1 灯检测到黑线 Y 大左转 大右转 N 2 灯检测到黑线 小左转 小右转 [在此处键入 ] (二) 软件程序 include include define uint unsigned int sbit l1= P2^0。 //四路寻迹模块接口第一路 sbit l2= P2^1。 //四路寻迹模块接口第二路 sbit r1= P2^2。 //四路寻迹模块接口第三路 sbit r2= P2^3。 //四路寻迹模块接口第四路 sbit IN12=P0^5。 //左马达 sbit IN11=P0^4。 sbit IN22=P0^3。 //右马达 sbit IN21=P0^2。 int f1,f2。 //标志位 int m。 define Left_moto_go {IN11=1,IN12=0。 } //左 轮前进 define Left_moto_back {IN11=0,IN12=1。 }// 左轮后退 define Left_moto_stp {IN11=0,IN12=0。 }//左轮停止 define Right_moto_go {IN21=1,IN22=0。 }//右轮前进 define Right_moto_back {IN21=0,IN22=1。 }//右轮后退 define Right_moto_stp {IN21=0,IN22=0。 }//右轮停止 void delay(uint k) //延时函数 { uint x,y。 for(x=0。 xk。 x++) for(y=0。 y110。 y++)。 } void run() //前进函数 { Left_moto_go。 Right_moto_go。 delay(30)。 Left_moto_stp。 Right_moto_stp。 delay(10)。 //调节转速 } void back(void) //后退函数 { Left_moto_back。 [在此处键入 ] Right_moto_back。 delay(20)。 //调节转速 Left_moto_stp。 Right_moto_stp。 delay(100)。 //调节转速 } void left() //左电机不动,右电机前进 { Left_moto_stp。 Right_moto_go。 delay(10)。 Left_moto_stp。 Right_moto_stp。 delay(40)。 } void right() //左电机前进,右电机不动 { Left_moto_go。 Right_moto_stp。 delay(10)。 Left_moto_stp。 Right_moto_stp。 delay(40)。 } void stop() { Left_moto_stp。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。