⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protect.c

📁 智能小车的往返行驶,单片机实现,使用红外信号进行路面信号的采集
💻 C
字号:
#include "SPCE061V004.h"
#define   FORWARD             0              //前进状态
#define   BACKWARD            1		         //后退状态
#define   STOP				  2				 //停止状态
#define   BLACKWIRE_H         7
typedef unsigned int uint;
extern uint SpeedValue;   //档位值,从1-100
extern uint Status;	      //记录和控制车前进,后退状态
extern uint Blackwire;	  //记录黑线数
extern uint S;			  //总路程,单位:厘米 	
extern uint Time;		  //总时间
extern uint key_array[8];
extern uint led[8];
void LEDdisplay( unsigned char , unsigned char  );
unsigned char  PointCTL(unsigned char );
void delay(uint );
void FaceBlackWire();
void Speed(uint speedvalue);
void ForeWheelForword();
void ForeWheelReverse();
void TurnLeft();
void TurnRight();
void Stop();
void Adjust();
void   NoMoveProtect();
uint t_buf_protect=0;
uint s_buf_protect=0;
uint times_protect=0;
void Protect()
{
  if(times_protect==0)
      {
      s_buf_protect=S;
      t_buf_protect=Time;
      times_protect=0x0f;
      }
   else if(t_buf_protect!=Time)
      {
         if ( (S-s_buf_protect)<8)
             {NoMoveProtect();t_buf_protect=Time;s_buf_protect=S;}
         else { s_buf_protect=S;t_buf_protect=Time;}
      }
   
}
void   NoMoveProtect()
{
 if(Status==  FORWARD  ) 
     {
        ForeWheelReverse();
        delay(0x45);
        TurnLeft();
        ForeWheelForword();
     }
 else if(Status==  BACKWARD ) 
    {
     ForeWheelForword();
     delay(0x45);
     TurnRight();
     ForeWheelReverse();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -