我会一直在 2015-09-16 23:21 采纳率: 0%
浏览 1506

刚进入大学 求教这个C语言编程 求教 求教

小车在下面 芯片AT89S52图片说明
这是我自己写的 求把加速减速停止写进去
#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&&(RightIR==0)&&(LeftIR==0))  
 {Forward(600);}                                                       //前进



if((RightIR==1)||(RightIR==))                                                //左weitiao
{
Left();
}


if((LeftIR==1)||(LeftIR==1))                                                      //右weitiao
{
Right();
}

}

}

  • 写回答

4条回答

  • 我会一直在 2015-09-16 23:21
    关注

    图片说明

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?