標(biāo)題: 單片機(jī)尋黑線程序 [打印本頁(yè)]

作者: stc89c52wzy    時(shí)間: 2019-4-6 15:19
標(biāo)題: 單片機(jī)尋黑線程序
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit P10=P1^0; //  控制左電機(jī)前進(jìn)
sbit P11=P1^1;//控制左電機(jī)后退
sbit P12=P1^2;//控制右電機(jī)
sbit P13=P1^3;//控制右電機(jī)
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==4&&P15==1&&P16==1)
     fun5();
  }
}

黑線.rar

3.4 KB, 下載次數(shù): 4, 下載積分: 黑幣 -5

循跡小車尋黑線程序






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