机器人智能躲开障碍物
来源:互联网 发布:日语翻译软件下载 编辑:程序博客网 时间:2024/05/01 03:32
/***********************************************************
功能:机器人能够智能躲避障碍物
说明:P1_0接左电机,P1_1接右电机
时间:2012.12.15
作者:荆轩道
************************************************************/
#include<BoeBot.h>
#include<uart.h>
#include <intrins.h>
#define LeftIR P1_5 //左边红外接收连接到P15
#define RightIR P3_6 //右边红外接收连接到P36
#define LeftLaunch P1_4 //左边红外发射连接到P14
#define RightLaunch P3_3 //右边红外发射连接到P33
int IRLaunch(unsigned char IR)
{
int counter;
if(IR=='L')
for(counter=0;counter<38;counter++)//左边发射
{
LeftLaunch=1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
LeftLaunch=0;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
}
if(IR=='R')
for(counter=0;counter<38;counter++)//右边发射
{
RightLaunch=1;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
RightLaunch=0;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
}
}
int main(void)
{
int i,pulseCount;
int pulseLeft,pulseRight;
bit irDetectLeft,irDetectRight;
uart_Init();
printf("Program Running!\n");
do
{
IRLaunch('R');
irDetectRight = RightIR; //右边接收
IRLaunch('L');
irDetectLeft = LeftIR; //左边接收
if((irDetectLeft==0)&&(irDetectRight==0)) //向前走
{
pulseCount=1;
pulseLeft=1700;
pulseRight=1300;
}
else if((irDetectLeft==1)&&(irDetectRight==0)) //右转
{
pulseCount=10;
pulseLeft=1300;
pulseRight=1300;
}
else if((irDetectLeft==0)&&(irDetectRight==1)) //左转
{
pulseCount=10;
pulseLeft=1700;
pulseRight=1700;
}
else //后退
{
pulseCount=15;
pulseLeft=1300;
pulseRight=1700;
}
for(i=0;i<pulseCount;i++)
{
P1_1=1;
delay_nus(pulseLeft);
P1_1=0;
P1_0=1;
delay_nus(pulseRight);
P1_0=0;
delay_nms(20);
}
}
while(1);
}
- 机器人智能躲开障碍物
- 智能机器人(跟随机器人)
- 让智能机器人更智能
- 智能机器人的学术探讨
- 智能聊天机器人小黄鸡
- 智能机器人“入侵”教育
- 关于机器人智能猜想
- veket智能机器人
- 智能聊天机器人
- Android智能问答机器人
- 智能机器人发展猜想
- 智能聊天机器人
- 智能制造不是机器人
- (转载)智能机器人。
- 智能聊天机器人
- 智能聊天机器人
- 关于智能机器人
- Android--智能机器人聊天
- 先锋论文检测软件,自动建立论文2012年12月18日:20
- 在大量类中实现花的自动化分类(英语较差,部分地方理解不到原著思想,不吝赐教)
- Delphi开源组件SynEdit
- 实验室设备管理系统项目总结(1)——Model层
- QT WindowsVS2010平台自行编译SDK的必要性验证
- 机器人智能躲开障碍物
- VS2010中水晶报表安装应用及实例
- HTML5技术标准初步定稿:功能日益完善
- string的应用
- 增强for循环(jkd1.5)
- Java学习笔记-HashMap
- 十七周:利用指针排序
- Prime Cryptarithm
- C++对象模型(1)——关于对象