標(biāo)題: 求助 [打印本頁(yè)]

作者: lxs123    時(shí)間: 2015-5-1 23:48
標(biāo)題: 求助
有人能幫忙做一個(gè)循跡小車的程序嗎
作者: quymc    時(shí)間: 2015-5-3 22:39
給你一個(gè)簡(jiǎn)單的三路循跡代碼
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P13=P1^3;
sbit P14=P1^4;
sbit P15=P1^5;
sbit P16=P1^6;
fun1()
{ P10=0;P11=1;P12=0;P13=1;}
//fun2()
//{ P10=1;P11=0;P12=1;P13=0;}
fun3()
{ P10=0;P11=1;P12=1;P13=1;}
fun4()
{ P10=1;P11=1;P12=1;P13=0;}
fun5()
{ P10=1;P11=1;P12=1;P13=1;}
void main()
{ while(1)
  { if((P14==0&&P15==1&&P16==0)||(P14==0&&P15==0&&P16==0))
          fun1();
    if(P14==1&&P15==0&&P16==0)
          fun4();
         if(P14==0&&P15==0&&P16==1)
         fun3();
        if(P10==1&&P15==1&&P16==1)
         fun5();
  }
}
作者: 騰飛的龍    時(shí)間: 2015-7-31 22:33
不錯(cuò)的程序




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1