51单片机洗衣机控制板及C语言程序
扫描二维码
随时随地手机看文章
51单片机洗衣机控制板及C语言程序,该控制板单片机采用AT89C51单片机,所设计全自动洗衣机功能有:标准洗衣、经济洗衣、单独洗衣以及排水四种洗衣等四种方式,有强洗、弱洗及运行/暂停、显示及报警功能,程序利用利用Protues仿真软件观察洗衣机的运行状态和过程。整个设计能达到预想的设计效果。
#include 'reg51.h'
#define uchar unsigned char
#define uint unsigned int
#define Enable(); EA=1;
#define Disable(); EA=0;
#define BIAOZHUN 0
#define JINGJI 1
#define DANDU 2
#define PAISHUI 3
#define QIANGXI 0
#define RUOXI 1
#define T_JinShui 240 //4min*60s
#define T_PaiShui 60 //1min*60s
#define T_XiDi 360 //6min*60s
#define T_PiaoXi_1 240 //4min*60s
#define T_PiaoXi_2 120 //2min*60s
#define T_TuoShui 120 //2min*60s
#define ZHENGZHUAN 0
#define STOP 1
#define FANZHUAN 2
#define ZhengZhuan(); PIN_Motor_A = 0; PIN_Motor_B = 1;
#define Stop(); PIN_Motor_A = 1; PIN_Motor_B = 1;
#define FanZhuan(); PIN_Motor_A = 1; PIN_Motor_B = 0;
#define ZanTing(); ET0 = 0; ET1 = 0; Stop();
#define JiXu(); ET0 = 1; ET1 = 1;
#define flag_Ok (flag_JinShui||flag_PaiShui||flag_XiDi||flag_PiaoXi||flag_TuoShui)
sbit LED_BiaoZhun = P1^0; //标准程序显示灯
sbit LED_JingJi = P1^1; //经济程序显示灯
sbit LED_DanDu = P1^2; //单独程序显示灯
sbit LED_PaiShui = P1^3; //排水程序显示灯
sbit LED_QiangXi = P1^4; //强洗状态灯
sbit LED_RuoXi = P1^5; //弱洗状态灯
sbit LED_XiDi = P1^6; //洗涤状态灯
sbit LED_PiaoXi = P1^7; //漂洗状态灯
sbit LED_TuoShui = P2^0; //脱水状态灯
sbit PIN_BaoJing = P2^1; //报警喇叭
sbit PIN_JinShui = P2^2; //进水控制
sbit PIN_PaiShui = P2^3; //排谁控制
sbit PIN_Motor_A = P2^4; //电机脚A
sbit PIN_Motor_B = P2^5; //电机脚B