目录
一、主要功能
** 基于AT89C51,L298N驱动两个电机,因为是平台,最后用两个电机驱动,然后第一个按键控制所有电机停止,第二个按键按下,电机顺时针转动,第三个按键按下,电机逆时针转动。然后加入pwm调速,分为高速和低速,并且LCD1602显示屏显示当前的平台状态,比如一开始所有电机是停止的,电机顺时针转动,LCD1602显示平台前翻,逆时针转动显示平台后翻,如果按第一个按键,即所有电机停止转动,则LCD1602显示平台静止。**
仿真图:
编辑原理图:
编辑
二、硬件资源
基于KEIL5编写C++代码,PROTEUS8.15进行仿真,全部资源在页尾,提供安装包。
本系统包含51单片机最小系统、LCD1602显示模块、L298N翻转模块、按键模块。
三、程序编程
#include <REGX52.H>
#include<intrins.h>
#include<stdio.h>
#include "Delay.h"
#include "LCD1602.h"
#define uchar unsigned char
#define uint unsigned int
typedef unsigned char u8;
typedef unsigned int u16;
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;
/*引脚定义*/
sbit Motor1_IN1 = P3^3; //电机IN1口
sbit Motor1_IN2 = P3^4;
sbit Motor1_EN = P3^2; //电机使能端1
sbit key1 = P1^4; //按键定义
sbit key2 = P1^5;
sbit key3 = P1^6;
sbit key4 = P2^4;
sbit key5 = P2<