机器人你叫我应实验实验报告
一、实验目的:
学会应用各种传感器。
二、实验要求:
要求机器人实现应答的功能、要求机器人可以根据指令作运动。
三、实验内容、步骤:
1、在较安静的情况下,机器人静止不动,当有人发出声音时,有节奏的回应。
2、在较安静的情况下,机器人静止不动,当有人发出声音时,机器人开始前进(躲避路途中的障碍)
四、实验代码:
#include "AS_UIII_LIB.h"
void tr()
{
int rot2;
rot2=rotation(2);
drive(0,30);
while(rotation(2)-rot2<16);
stop();
}
void tl()
{
int rot1;
rot1=rotation(1);
drive(0,-30);
while(rotation(1)-rot1<16);
stop();
}
void goon()
{
int rot1;
rot1=rotation(1);
drive(40,0);
while(rotation(1)-rot1<100);
stop();
}
void main()
{
int i,ir;
while(1)
{
if(microphone()>150)
{
if(microphone()>150) {
drive(40,0);
for(i=0;i<50;i++) {
i++;
wait(0.01);
ir=ir_detector(); if(ir!=0) {
i++;
wait(0.01);
ir=ir_detector(); if(ir!=0) {
Beep(); tr(); goon(); tl(); goon(); tl(); goon(); tr();
drive(40,0); }
}
wait(0.01); }
}
stop();
}
}
}
五、实验结果:
按下运行按钮后,在机器人听到比较大的声响是向前移动,如果遇到障碍则绕障,当声音停止时机器人不动。
六、实验小结:
通过这次实验我学会了声音传感器的使用方法,为进一步学习打下基础。
第二篇:机器人灭火实验实验实验报告
机器人灭火实验实验实验报告
一、实验目的:
接触比较大规模的编程,激发学习和创新能力。通过灭火的程序对JC的知识进行全面的巩固,熟练应用各种传感器。
二、实验要求:
要求使用JC代码编程。
三、实验内容、步骤:
1、机器人巡查火场各个房间,不重复,发现火源,灭火。
2、趋光
3、沿墙走
四、实验代码:
#include "AS_UIII_LIB.h"
int ir_1=0;
void main()
{
// 直走找墙壁并转向让墙壁在左边
drive(5,0);
while(1)
{
if(ir_detector()!=0)
if(ir_detector()!=0)
{
drive(0,2);
while(1) if(ir_detector()==1) if(ir_detector()==1) break; stop();
break;
}
}
//沿墙壁走
drive(2,-2);
while(1)
{
if(ir_detector()==2||ir_detector()==4)
{
drive(0,2);
while(1) if(ir_detector()==0) if(ir_detector()==0) break;
rot_1=rotation(1);
drive(2,0);//go straight
while(rotation(1)-rot_1<10);
if((photo(1)+photo(2))/2<950) break;
rot_1=rotation(1);
drive(2,2);//turn right
while(rotation(1)-rot_1<20);
stop();
}
drive(2,-2);
}
while(1)
{
if(photo(1)>photo(2))
{
drive(20,20);
wait(0.5);
stop();
}
else
{
drive(20,-20);
wait(0.5);
stop();
}
if((photo(1)+photo(2))/2<750) break;
}
while(1){Beep();wait(0.5);}
}
五、实验结果:
按下运行按钮之后,机器人先直走一段路程找墙壁,检测到障碍(墙壁)后,机器人原地旋转,使墙壁在机器人的左边,然后开始沿墙走,发现光源后左右前进到光源处报警。
六、实验小结:
通过这次实验,我学会了联合使用光传感器和红外传感器的方法,为进一步学习打下基础。