按下仿真按钮后 没有任何反应
按下前进按键 小车全速前进 电机速度(两端电压)大概为69.2
按下后退按键 小车全速后退 电机速度(两端电压)大概为-69.2
按下左转弯按键 小车左转弯 左前轮左后轮速度(两端电压)大概30左右
右前轮右后轮速度(两端电压)大概50左右
按下右转弯按键 小车右转弯 左前轮左后轮速度(两端电压)大概50左右
右前轮右后轮速度(两端电压)大概30左右
按下停止按键 小车停止
完整版 电路图和程序代码 下载地址
https://pan.baidu.com/s/1ezbAVgVpEnphNoweASrwzg?pwd=8888
部分代码展示
#include<reg52.h>
#define uInt unsigned int
#define uChar unsigned char
#define PWM_MIN_STATE 300
#define PWM_MAX_STATE 700
uInt Time;
uInt Time1;
uInt Time2;
uInt Time3;
sbit ForwardKey = P1^0;
sbit BackKey = P1^1;
sbit TurnLeftKey = P1^2;
sbit TurnRightKey = P1^3;
sbit StopKey = P1^4;
sbit LeftFront1 = P0^0;
sbit LeftFront2 = P0^1;
sbit LeftFrontC = P2^0;
sbit LeftBehind1 = P0^2;
sbit LeftBehind2 = P0^3;
sbit LeftBehindC = P2^1;
sbit RightFront1 = P0^4;
sbit RightFront2 = P0^5;
sbit RightFrontC = P2^2;
sbit RightBehind1 = P0^6;
sbit RightBehind2 = P0^7;
sbit RightBehindC = P2^3;
void DelayMS(uInt t)
{
uInt i,j;
for(i=0;i<t;i++)
for(j=0;j<125;j++)
;
}
void CarMove()
{
LeftFront1=1;
LeftFront2=0;
LeftFrontC=1;
LeftBehind1=1;
LeftBehind2=0;
LeftBehindC=1;
RightFront1=1;
RightFront2=0;
RightFrontC=1;
RightBehind1=1;
RightBehind2=0;
RightBehindC=1;
}
void CarBack()
{
LeftFront1=0;
LeftFront2=1;
LeftFrontC=1;
LeftBehind1=0;
LeftBehind2=1;
LeftBehindC=1;
RightFront1=0;
RightFront2=1;
RightFrontC=1;
RightBehind1=0;
RightBehind2=1;
RightBehindC=1;
}
void TIM0Init()
{
TMOD=0x01; //定时器工作方式1
TH0=(65536-1000)/256; //初值高8位
TL0=(65536-1000)%256; //初值低8位
EA=1; //开总中断
ET0=1; //开启定时器0中断
}
void TIM1Init()
{
TMOD=0x10; //定时器工作方式1
TH1=(65536-1000)/256; //初值高8位
TL1=(65536-1000)%256; //初值低8位
EA=1; //开总中断
ET1=1; //开启定时器0中断
}