📄 wash.lst
字号:
C51 COMPILER V8.02 WASH 06/05/2008 18:57:26 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE WASH
OBJECT MODULE PLACED IN wash.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE wash.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************************
2 题目:洗衣机控制C语言版
3 说明:参考成都木马科技有限公司《单片机与仿真》光盘中的例子制作的。
4 作者:kaka000 论坛:http://www.proteus.com.cn
5 日期:07年10月13日
6 ******************************************************************************
7 使用说明:
8 a.先选择“强“”弱”-----按“选择”键切换灯到到“强”,再按“增加、确定”键
9 b.洗衣时间定时-----切换到洗衣时间,在按“增加、确定”键或“减少”键,OK后切换
10 到脱水时间,同样设定脱水时间和洗涤次数。
11 设定好后,切换到准备,按“增加、确定”键开始工作。
12 开始工作时,P2.0的灯亮(其实是代替电子水龙头的“开”),
13 这时候等待水满,这里我是手动给他一个高电平(点FULL的逻辑开关),这时开始洗衣,
14 洗衣时间减到0时,次数减1,再洗(洗衣时间恢复,---即洗衣时间是指每次的洗衣时间,
15 不是总的时间)
16 当次数减到0时P2.1的灯亮(其实是代替电子水龙头的“关”),
17 这时候等待水放完,这里我再手动给他一个高电平(点empty的逻辑开关),这时开始脱水,
18 电机启动,等到脱水时间减到0时,p2.7的灯亮(灯是代替喇叭的),等待下一次洗衣。
19 按“启动”键,系统复位。开始下一次洗衣的设定。
20 ******************************************************************************/
21 #include <AT89X51.H>
22 unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,
23 0x7d,0x07,0x7f,0x6f,0x00};
24 unsigned char dispbitcode[]={0xfe,0xfd,0xfb,0xf7,
25 0xef,0xdf,0xbf,0x7f};
26
27 unsigned char dispbuf[2]={0,0};
28 unsigned char dispbitcnt;
29
30 unsigned char second;
31 unsigned char minite;
32 unsigned int tcnt;
33 unsigned char mstcnt;
34 unsigned char i,j;
35
36 sbit full=P2^5;
37 sbit empty=P2^6;
38 unsigned char temp;
39
40 unsigned char startok;
41
42 unsigned char ID;
43 unsigned char keye;
44 unsigned char ready;
45
46 unsigned char uwtime;
47 unsigned char hwtime;
48 unsigned char count;
49 char utime;
50 char htime;
51 char cnt;
52
53 unsigned char strong;
54 unsigned char weak;
55 unsigned char power;
C51 COMPILER V8.02 WASH 06/05/2008 18:57:26 PAGE 2
56
57 //延时1ms子程序****************************************************************
58 void delay1ms(void)
59 {
60 1 unsigned char i,j;
61 1 for(i=2;i>0;i--)
62 1 for(j=248;j>0;j--);
63 1 }
64 //延时200ms子程序****************************************************************
65 void delay02s(void)
66 {
67 1 unsigned char i;
68 1 for(i=200;i>0;i--)
69 1 {
70 2 delay1ms();
71 2 }
72 1 }
73 void main(void)
74 {
75 1 rst:TMOD=0x02;
76 1 TH0=0x06;
77 1 TL0=0x06;
78 1 TR1=1;
79 1 ET0=1;
80 1 TH1=0x06;
81 1 TL1=0x06;
82 1 ET1=1;
83 1 EA=1;
84 1 P0_5=0;
85 1 P0_6=0;
86 1 P0_7=0;
87 1 P2=0;
88 1
89 1 startok=0;
90 1 ID=0;
91 1 keye=1;
92 1 ready=0;
93 1
94 1 uwtime=0;
95 1 hwtime=0;
96 1 count=0;
97 1
98 1 utime=0;
99 1 htime=0;
100 1 cnt=0;
101 1
102 1 strong=0;
103 1 weak=0;
104 1 power=0;
105 1
106 1 while(1)
107 1 {
108 2 //洗衣模式选择//
109 2 if(keye==1)
110 2 {
111 3 if(P0_0==0)
112 3 {
113 4 delay1ms();
114 4 //选择键功能//
115 4 if(P0_0==0)
116 4 {
117 5 ID++;
C51 COMPILER V8.02 WASH 06/05/2008 18:57:26 PAGE 3
118 5 if(ID==6)
119 5 {
120 6 ID=0;
121 6 }
122 5 while(P0_0==1);
123 5 }
124 4 switch(ID)
125 4 {
126 5 case 0:
127 5 ready=1;
128 5 strong=0;
129 5 weak=0;
130 5 hwtime=0;
131 5 uwtime=0;
132 5 count=0;
133 5 dispbuf[0]=10;
134 5 dispbuf[1]=10;
135 5 P0_5=0;
136 5 P0_6=0;
137 5 P0_7=0;
138 5 delay02s();
139 5 break;
140 5 case 1: //strong; 强洗
141 5 strong=1;
142 5 weak=0;
143 5 hwtime=0;
144 5 uwtime=0;
145 5 count=0;
146 5 dispbuf[0]=power%10;
147 5 dispbuf[1]=power/10;
148 5 P0_5=0;
149 5 P0_6=0;
150 5 P0_7=1;
151 5 delay02s();
152 5 break;
153 5 case 2: //weak; 弱洗
154 5 strong=0;
155 5 weak=1;
156 5 hwtime=0;
157 5 uwtime=0;
158 5 count=0;
159 5 dispbuf[0]=power%10;
160 5 dispbuf[1]=power/10;
161 5 P0_5=0;
162 5 P0_6=1;
163 5 P0_7=0;
164 5 delay02s();
165 5 break;
166 5 case 3: //hwtime; 洗衣时间
167 5 strong=0;
168 5 weak=0;
169 5 hwtime=1;
170 5 uwtime=0;
171 5 count=0;
172 5 dispbuf[0]=htime%10;
173 5 dispbuf[1]=htime/10;
174 5 P0_5=0;
175 5 P0_6=1;
176 5 P0_7=1;
177 5 delay02s();
178 5 break;
179 5 case 4: // uwtime; 脱水时间
C51 COMPILER V8.02 WASH 06/05/2008 18:57:26 PAGE 4
180 5 strong=0;
181 5 weak=0;
182 5 hwtime=0;
183 5 uwtime=1;
184 5 count=0;
185 5 dispbuf[0]=utime%10;
186 5 dispbuf[1]=utime/10;
187 5 P0_5=1;
188 5 P0_6=0;
189 5 P0_7=0;
190 5 delay02s();
191 5 break;
192 5 case 5: //count; 洗涤次数
193 5 strong=0;
194 5 weak=0;
195 5 hwtime=0;
196 5 uwtime=0;
197 5 count=1;
198 5 dispbuf[0]=cnt%10;
199 5 dispbuf[1]=cnt/10;
200 5 P0_5=1;
201 5 P0_6=0;
202 5 P0_7=1;
203 5 delay02s();
204 5 break;
205 5 }
206 4 }
207 3 //启动键功能//
208 3 if(P0_1==0) //启动
209 3 {
210 4 delay1ms();
211 4 if(P0_1==0)
212 4 {
213 5 if(ready==1) //准备OK
214 5 {
215 6 startok=1;
216 6 }
217 5 }
218 4 }
219 3 //加 -- 确定键功能//
220 3 if(P0_2==0)
221 3 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -