1、car.h文件,进行管脚定义、函数原型声明和通信编码的宏定义
#ifndef _CAR_H_
#define _CAR_H_
#include <reg51.h>
/*开发板的红外遥控器发来的通信编码的宏定义,如果用开发板的遥控器,则启用下面的宏定义*/
/*
#define FORWARD_INSTRUCTION 0x40 //前进
#define BACKEOFF_INSTRUCTION 0x19 //后退
#define TURNRIGHT_INSTRUCTION 0x09 //右转
#define TURNLEFT_INSTRUCTION 0x07 //左转
#define RETURNING_INSTRUCTION 0x15 //回正
#define SPEED0_INSTRUCTION 0x16 //速度停止
#define GEAR_1ST 0x0c //1挡
#define GEAR_2ND 0x18 //2挡
#define GEAR_3RD 0x5e //3挡
#define GEAR_4TH 0x08 //4挡
#define STOP 0x45 //停车
*/
/*电视机的遥控器发来的通信编码的宏定义,如果用开发板的遥控器,则启用下面的宏定义*/
#define FORWARD_INSTRUCTION 0xca //前进
#define BACKEOFF_INSTRUCTION 0xd2 //后退
#define TURNRIGHT_INSTRUCTION 0xc1 //右转
#define TURNLEFT_INSTRUCTION 0x99 //左转
#define RETURNING_INSTRUCTION 0xce //回正
#define SPEED0_INSTRUCTION 0x87 //速度停止
#define GEAR_1ST 0x92 //1挡
#define GEAR_2ND 0x93 //2挡
#define GEAR_3RD 0xcc //3挡
#define GEAR_4TH 0x8e //4挡
#define STOP 0xdc //停车
/*重定义单片机管脚*/
sbit gear_1 = P0^0;
sbit gear_2 = P0^1;
sbit gear_3 = P0^2;
sbit gear_4 = P0^3;
sbit forward = P0^4;
sbit backoff = P0^5;
sbit turnright = P0^6;
sbit turnleft = P0^7;
/*声明函数原型*/
void Speed_0();
void Speed_1(