399 基于51单片机仿真智能小车控制系统【毕设课设】

按下仿真按钮后  没有任何反应
按下前进按键    小车全速前进  电机速度(两端电压)大概为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中断
}

  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值