单片机自动洗衣机程序Word格式文档下载.docx
- 文档编号:5801327
- 上传时间:2023-05-05
- 格式:DOCX
- 页数:28
- 大小:18.70KB
单片机自动洗衣机程序Word格式文档下载.docx
《单片机自动洗衣机程序Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《单片机自动洗衣机程序Word格式文档下载.docx(28页珍藏版)》请在冰点文库上搜索。
P0=0xff;
//P0口作为输入
delay
(1);
RS=0;
RW=1;
E=1;
while(P0&
0X80);
E=0;
RW=0;
P0=0X00;
}
voidWrite_Lcd(bitCom_Data,unsignedcharDat)
Check_Busy();
if(Com_Data)//若为写数据指令
RS=1;
else
RS=0;
P0=Dat;
voidInit_Lcd(void)//初始化
Write_Lcd(Write_Command,0x38);
//设置16x2显示,5x7点阵,8位数据接口
Write_Lcd(Write_Command,0x0c);
//开显示,不显示光标
Write_Lcd(Write_Command,0x06);
//地址指针加1,且光标加1,整屏显示不移动
Write_Lcd(Write_Command,0x01);
//清屏
voidmain()
EA=1;
//开总中断
ET0=1;
//开内部中断0
TMOD=0x11;
TH0=0xe1;
//计数器0高八位
TL0=0x48;
//计数器0低八位
TR0=1;
sound=0;
X=0;
//默认为标准状态
Y=0;
//默认为强洗
Z=0;
//默认为高水位
Init_Lcd();
while
(1)
{
Write_Lcd(Write_Command,0x80+0x40);
Write_Lcd(Write_Data,ht+48);
//小时高位
Write_Lcd(Write_Data,ho+48);
//小时低位
Write_Lcd(Write_Data,10+48);
//冒号
Write_Lcd(Write_Data,mint+48);
//分钟高位
Write_Lcd(Write_Data,mino+48);
//分钟低位
//冒号
Write_Lcd(Write_Data,st+48);
//秒高位
Write_Lcd(Write_Data,so+48);
//秒低位
Key_temp=Key_process();
//键扫描
switch(Key_temp)
{
case0:
begin();
break;
case4:
case8:
case12:
case1:
Y=1;
case5:
Z=1;
case6:
case15:
p_trevise();
//设置北京时间
default:
}
}
voidbegin()
{X=Key_temp
switch(X)
case0:
run1();
//转到标准洗衣程序
case4:
run2();
//转到经济洗衣程序
case8:
run3();
//转到单独洗衣程序
case12:
run4();
//转到排水洗衣程序
default:
break;
}
voiddelay(unsignedintn)//延时函数
unsignedchari,j;
j=100;
j=n*j;
for(i=0;
i<
j;
i++);
voidShow_Lcd1()//标准
unsignedchari;
Write_Lcd(Write_Command,0x80);
2;
i++)
Write_Lcd(Write_Data,table[i]);
voidShow_Lcd2()//经济
for(i=2;
4;
Write_Lcd(Write_Data,table[i]);
voidShow_Lcd3()//单独
for(i=4;
6;
voidShow_Lcd4()//排水
Write_Lcd(Write_Command,0x84);
for(i=6;
8;
voidShow_Lcd41()//洗衣程序里的排水
voidShow_Lcd5()//进水
for(i=8;
10;
voidShow_Lcd6()//洗涤
for(i=10;
12;
voidShow_Lcd7()//漂洗
for(i=12;
14;
voidShow_Lcd8()//脱水
for(i=14;
16;
voidShow_Lcd9()//强洗
Write_Lcd(Write_Command,0x87);
for(i=16;
17;
voidShow_Lcd10()//弱洗
for(i=17;
18;
unsignedcharKey_process()//键盘扫描程序
staticunsignedcharKey_temp=0xff;
unsignedchartemp;
P1&
=0xf0;
//P1口低四位作为数字输入时应往相应引脚写0
P2&
//置列扫描信号为0
temp=P1&
0x0f;
Key_temp=0xff;
if(temp!
=0x0f)//P1口低四位不全为1,则有键被按下11110000
delay
(1);
//延时消抖
if(temp==(P1&
0x0f))//消抖后再判断键值
P2|=0x07;
//P2.3为0
switch(P1&
0x0f)
{
case0x0e:
Key_temp=0;
case0x0d:
Key_temp=4;
case0x0b:
Key_temp=8;
case0x07:
Key_temp=12;
}
while(p11==0||p10==0||p12==0||p13==0);
P2&
P2|=0x0b;
//P2.2为0
Key_temp=1;
Key_temp=5;
Key_temp=9;
Key_temp=13;
P2|=0x0d;
//P2.1为0
Key_temp=2;
Key_temp=6;
Key_temp=10;
Key_temp=14;
}
P2|=0x0e;
//P2.0为0
Key_temp=3;
Key_temp=7;
Key_temp=11;
Key_temp=15;
}
returnKey_temp;
voidrun1()
Show_Lcd1();
if(Y==1)
Show_Lcd10();
Show_Lcd9();
while
(1)
{
if(Z==1)
minc=21;
sc=0;
while
(1)
{
show();
//显示北京时间
Key_temp=Key_process();
switch(Key_temp)
{
case9:
park=!
park;
case13:
main();
case2:
park1=!
park1;
sound=1;
jj=2;
while(jj);
sound=0;
}
switch(minc)
case20:
Show_Lcd5();
case19:
Show_Lcd6();
case14:
Show_Lcd4();
case12:
Show_Lcd7();
case8:
case7:
case6:
case1:
Show_Lcd8();
if(minc==0&
&
sc==0)
Write_Lcd(Write_Command,0x01);
sound=1;
jj=2;
while(jj);
sound=0;
main();
else
minc=27;
jj=2;
case26:
case25:
case17:
case15:
case11:
case3:
}
voidrun2()
Show_Lcd2();
minc=15;
minc=19;
case18:
case16:
voidrun3()
Show_Lcd3();
minc=6;
case5:
case4:
if(minc==0&
minc=7;
Key_temp=Key_process();
sound=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机 自动 洗衣机 程序
![提示](https://static.bingdoc.com/images/bang_tan.gif)