目录
一、主要功能
用直流电机转动模拟洗衣机。要求
有弱洗、普通洗、强洗三种模式,可通过按键选择。可以设置洗衣时长,通关按键选择15、30、45、60、90分钟。时间到蜂鸣器报警提示。LCD 显示相关信息。
仿真图:
编辑
二、硬件资源
基于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;
uchar count = 0,flag = 0; //定时中断次数
uchar time=0,mode=0,sec=0;//系统变量
uchar fen=0,miao=0,set=0;//时间
uchar miao1=0;//倒计时
uchar disp1\[\]="00:00";
uchar disp2\[\]="00s";
sbit Motor1_IN1 = P1^1;
sbit Motor1_IN2 = P1^2;
sbit key1 = P3^0; //按键引脚
sbit key2 = P3^1;
sbit key3 = P3^2;
sbit key4 = P3^3;
sbit key5 = P3^4;
sbit key6 = P3^5;
sbit key7 = P3^6;
sbit key8 = P3^7;
sbit beep = P1^0; //蜂鸣器引脚
void keypd();
void main()