#include <reg51.h> /*地址头文件*/
#include <absacc.h> /*绝对地址访问头文件*/
#include <math.h> /*数学库函数*/
#include <intrins.h> /*内部函数库*/
#define IN0 XBYTE[0x2030] /* 0809通道0地址 */
#define w_c_add XBYTE[0x2070] /* lcd写命令字地址 */
#define w_d_add XBYTE[0x2071] /* lcd写数据地址 */
#define r_s_add XBYTE[0x2072] /* lcd读状态字地址 */
#define r_d_add XBYTE[0x2073] /* lcd读数据地址 */
#define c8279 XBYTE [0x2021] /* 8279命令/状态口的地址 */
#define d8279 XBYTE [0x2020] /* 8279数据口地址 */
unsigned char water_level;/*水位*/
unsigned char wash_power;/*洗涤强度*/
unsigned char wash_power1;
unsigned char piao_time;/*漂洗次数*/
unsigned char m;
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,
0x77,0x7c,0x39,0x5e,0x79,0x71}; /* 字型表 */
unsigned char code TAB1[8] = {0x10,0x30,0x20,0x60,0x40,0xC0,0x80,0x90};//电机正转
unsigned char code TAB2[8] = {0x90,0x80,0xC0,0x40,0x60,0x20,0x30,0x10};//电机反转
unsigned char bdata status; /* 可位寻址片内数据存储器,允许位与字节混合访问 */
sbit busy=status^7; /*“忙”线的第7位*/
sbit clflag=ACC^7; /*8279查询位*/
unsigned char key;
unsigned char keyflag=0;
unsigned char Min;
unsigned char Sec;
unsigned char TimeEnd=0;
unsigned char ZTime;
sbit Speaker=P3^6; /*蜂鸣器*/
sbit Led=P3^0; /*Led小灯*/
sbit Led1=P3^1; /*Led小灯*/
void alarm(unsigned int t);
void delay(unsigned int t);
void delay1(unsigned char n);
void DaoJiShi();
void TimeSelect();
void lcd_num(unsigned char i,unsigned char j,unsigned char num);
void lcd_string(unsigned char i,unsigned char j,unsigned char *s);
void lcd_clr(); /*LCD清除程序*/
void init_lcd(); /*LCD初始化*/
void lcd_busy(void); /*LCD忙状态检测函数 */
void init_8279(void);
unsigned char adc0809();
void play0809(unsigned char m,unsigned char n);
void MotorChoose();
void MotorChoose1();
void ZdCanShu();
void PxTimes();
void XdPower();
void ShuiWei();
void ShangShui();
void QinPao();
void TuoShui();
void XiDi();
void ShuaiGan();
void PiaoXi();
/*******************************************************************************
主函数
*******************************************************************************/
void main()
{ unsigned char j;
init_lcd();
init_8279();
while(key!=0x0f); /*按f开启洗衣机*/
alarm(2);
keyflag=0;
lcd_string(1,1,"****************");
lcd_busy();
lcd_string(2,1,"欢迎使用洗衣机");
lcd_busy();
lcd_string(3,1,"按任意键继续");
lcd_busy();
lcd_string(4,1,"****************");
while(keyflag!=1);
alarm(2);
keyflag=0;
lcd_clr();
lcd_busy();
lcd_string(2,3,"开始工作!");
delay(5);
lcd_busy();
lcd_string(2,1,"请选择使用模式");
delay(5);
lcd_clr();
lcd_clr();
lcd_busy();
lcd_string(1,1,"0 - 全自动模式");
lcd_string(2,1,"1 - 浸泡");
lcd_string(2,5,"2 - 洗涤");
lcd_string(3,1,"3 - 漂洗");
lcd_string(3,5,"4 - 甩干");
while(1!=keyflag);
alarm(2);
keyflag=0;
lcd_clr();
switch(key)
{
case 0:
{ ZdCanShu();
/*********************上水**************************/
lcd_busy();
lcd_string(4,1,"请按确认键");
while(key!=0x0e); /*按e确认*/
alarm(1);
keyflag=0;
lcd_clr();
lcd_busy();
lcd_string(1,1,"上水中");
ShangShui();
delay(5);
/*******************浸泡***************************/
QinPao();
delay(2);
/*********************洗涤**************************/
XiDi();
delay(2);
/*********************脱水**************************/
TuoShui();
delay(2);
/*********************漂洗**************************/
PiaoXi();
delay(2);
/*********************甩干**************************/
ShuaiGan();
delay(2);
break;
}
case 1:
{ ShuiWei();
/*********************上水**************************/
lcd_busy();
lcd_string(3,1,"请按确认键");
while(key!=0x0e); /*按e确认*/
alarm(1);
keyflag=0;
lcd_clr();
lcd_busy();
lcd_string(1,1,"上水中");
ShangShui();
delay(5);
/*******************浸泡***************************/
QinPao();
break;
}
case 2:
{ ShuiWei();
XdPower();
/*********************上水**************************/
lcd_busy();
lcd_string(3,1,"请按确认键");
while(key!=0x0e); /*按e确认*/
alarm(1);
keyflag=0;
lcd_clr();
lcd_busy();
lcd_string(1,1,"上水中");
ShangShui();
delay(5);
/*********************洗涤**************************/
XiDi();
delay(2);
/*********************脱水**************************/
TuoShui();
delay(2);
break;
}
case 3:
{ ShuiWei();
PxTimes();
lcd_busy();
lcd_string(3,1,"请按确认键");
while(key!=0x0e); /*按e确认*/
alarm(1);
keyflag=0;
/*********************漂洗**************************/
PiaoXi();
delay(2);
break;
}
case 4:
{/*********************甩干**************************/
lcd_clr();
lcd_busy();
lcd_string(2,1,"请按确认键");
while(key!=0x0e);
alarm(1);
keyflag=0;
ShuaiGan();
delay(2);
break;
}
default:break;
}
lcd_clr();
while(j<5)
{
alarm(2);
delay(2);
lcd_busy();
lcd_string(2,3,"工作结束!");
j++;
}
lcd_clr();
while(1);
}
/*******************************************************************************
函数名:delay
函数功能:延时函数
*******************************************************************************/
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
{
for(j=0;j<30000;j++);
}
}
/*******************************************************************************
函数名:delay1
函数功能:延时xms函数
*******************************************************************************/
void delay1(unsigned char t)
{ unsigned int i,j;
for(i=0;i<t;i++)
{
for(j=0;j<60;j++);
}
}
/**
评论0
最新资源