两个或三个QTI循线传感器 芯片是AT89S52
好运好运必须使用installShield这种打包工具把源程序打成安装文件后才能在其他机器上安装使用
好运好运必须使用installShield这种打包工具把源程序打成安装文件后才能在其他机器上安装使用
这是我自己编的,加速减速 停止编了好久也没有编进去
#include
#include
#define LeftIR P1_2 //左边红外接收连接到P12
#define RightIR P1_3 //右边红外接收连接到P13
void Forward(int Velocity)
/* Velocity should be between 0 and 200 */
{
P1_1=1;
delay_nus(1500+ Velocity);
P1_1=0;
P1_0=1;
delay_nus(1500- Velocity);
P1_0=0;
delay_nms(80);
}
void Left()
/* Velocity should be between 0 and 200 */
{
P1_1=1;
delay_nms(20);
P1_1=0;
P1_0=0;
P1_0=0;
delay_nus(1300);
}
void Right()
/* Velocity should be between 0 and 200 */
{
P1_1=0;
P1_1=0;
P1_0=1;
delay_nus(1300);
P1_0=0;
delay_nms(20);
}
void Backward(int PulseCount,int Velocity)
/* Velocity should be between 0 and 200 */
{
int i;
for(i=1;i<= PulseCount;i++)
{
P1_1=1;
delay_nus(1500-Velocity);
P1_1=0;
P1_0=1;
delay_nus(1500+ Velocity);
P1_0=0;
delay_nms(20);
}
}
int main(void)
{
while(1)
{
uart_Init();
printf("Program Running!\n");
if((zhongIR==1)&&(RightIR==0)&&(LeftIR==0))
{Forward(600);} //前进
if((RightIR==1)||(RightIR==1)) //左weitiao
{
Left();
}
if((LeftIR==1)||(LeftIR==1)) //右weitiao
{
Right();
}
}
}