?? seektrack..c
字號:
/***********************************************************************
_SEEKTRACK_C_
A.Description:This file contains the functions of the basic program
of motors' driving and the program for seeking.
B. Wenzhuo Fu
Electic Class7
Sep20,2008
Bulid with Keil uVision3 .
**********************************************************************/
#include<seektrack.h>
#include<regx52.h>
/***********************************************************************
**********************************************************************/
void motor(bit lf,bit lb,bit rf,bit rb)
{
lfward = lf ;
lbward = lb ;
rfward = rf ;
rbward = rb ;
}
/***********************************************************************
motor(0,0,0,0); 停止 motor(1,0,1,0); 向前 motor(1,0,0,1); 向右
motor(0,1,1,0); 向左 motor(0,1,0,1); 向后
**********************************************************************/
void stop()
{ motor(0,0,0,0);}
void forward()
{P3_4=!P3_4;
motor(1,0,1,0);}
void turnright()
{ motor(1,0,0,1);}
void turnleft()
{ motor(0,1,1,0);}
void backward()
{ motor(0,1,0,1);}
/***********************************************************************
形式參數: i=0:向前,i=1:向右,i=2:向左.
**********************************************************************/
void seek(unsigned int i)
{
P3_3=!P3_3;
if(i==0 )
{if( _rseek && !_lseek)
{r_trend =0; l_trend =1; }
if( _lseek && !_rseek)
{r_trend =1; l_trend =0; }
if(!_lseek&&!_rseek&&!_cseek)
{if( r_trend) turnleft();
if( l_trend) turnright(); }
else forward(); }
if(i==1 )
{if( _rseek )
{l_trend=1; r_trend =0; turnright(); }
if( _lseek && !_cseek)
{r_trend =1; l_trend =0; }
if(!_lseek)
{if( r_trend) turnleft();
if( l_trend) turnright(); }
else motor(1,0,1,0); }
/*
if(i==2 )
{if( _lseek )
{r_trend=1; l_trend =0; turnleft (); }
if( _rseek && !_cseek)
{r_trend =0; l_trend =1; }
if(!_rseek )
{if( r_trend) turnleft ();
if( l_trend) turnright (); }
else forward (); }*/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -