I need help with the washing machine course design. Please help me modify the program. Thank you.
[Copy link]
Please help me save my child's course design and modify the program. Thank you. #include #define uchar unsigned char #define uint unsigned int //********************************// sbit key_mianzhi=P1^4; // Cotton key sbit key_on=P1^5; // Start key sbit key_off=P1^6; // End button sbit key_sizhi=P1^7; // Silk button sbit key_huaxian=P1^1; // Chemical fiber button //******************************// sbit led_wring=P0^7; // Alarm indicator light //**********************************// uchar codenum[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //************************************// char sec=0; // Time in seconds char min=0; // Time division uchar count=0; // Interrupt count uchar flag0=0; // Washing machine working status flag uchar flag1=0; // piaoxiFlag uchar flag2=0; // qiangxiflag uchar flag3=0; // ruoxiflag uchar err=0; // alarm flag //**************************************// void delay(); // Delay function void over(); // End subroutine void piaoxi(); // Ticket subroutine void ruoxi(); // Weak subroutine void qiangxi(); // Strong subprogram void on(); // WorkonProcessing subroutine void se(); // Display menu selection void SEG_display(); // Display time subroutine void key_scan(); // Key scanning subroutine ************************************ void delay(uint i) { uintx,y; for(x=i;x>0;x--) for(y=120;y>0;y--); [size=12.0pt ]} //*********WorkonProcessing subroutine**********// void on() { TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; [size=12. 0pt] P0 = 0xff; if(flag0==0) in(); if(flag0==1) qiangxi (); if(flag0==2) piaoxi(); if(flag0==3) ruoxi(); if(flag0== 4) out(); } //********End subroutine**********// void over() { other=0; anther=0; P0=0xff; mo_r=0; [size=1 2.0pt] mo_l=0; led_over=0; EA=0; } //************[size= 12.0pt]进水子程序**********// voidin() { anther=0; other=0; P0=0xff; led_in=0; flag1++; mo_r=0; mo_l=0; min=0; sec=8; } //**********漂洗子程序**********// void piaoxi() { anther=1; other=0; P0=0xff; mo_r=1; mo_l=1; min=0; sec=10; quan=0; } // //********强洗程序********// void piaoxi() { anther=1; other=0; P0=0xff; mo_r=1; mo_l=0; min=1; sec=10; } //*********弱洗子程序********// void ruoxi() { other=1; anther=0; P0=0xff; mo_r=1; mo_l=0; sec=5; } //*********漂洗子程序********// void piaoxi() { other=1; anther=0; P0=0xff; mo_r=1; sec=5; mo_l=1; sec=5; } //*********按键扫描子程序*********// void key_scan() { if(key_menu==0) { delay(5); if(key_menu==0) { while(!key_menu); menu(); } } //********************************// if(key_on==0) { delay(5); if(key_on==0) { while(!key_on); on(); } } //*********************************// if(key_off==0) { delay(5); if(key_off==0) { while(!key_off); over(); } } } //*********显示子程序**********// void SEG_display() { P1=0x01; P2=num[min/10]; delay(10); P1=0x02; P2=num[min%10]; delay(10); P1=0x04; P2=num[sec/10]; delay(10); P1=0x08; P2=num[sec%10]; delay(10); } //*********主函数**********// void main() { led_in=0; anther=0; other=0; while(1) { SEG_display(); key_scan(); } } //*****定时器0中断处理程序*****// void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; count++; if(count==20) { count=0; sec--; if((flag0==1)||(flag0==2)) { quan++; switch(quan) { case 1:mo_r=1;mo_l=0;break; case10:mo_r=0;mo_l=0;break; case15:mo_r=0;mo_l=1;break; case25:mo_r=0;mo_l=0;break; default:; } if(quan==30) { quan=0; } } //**********************************// if((sec==0)&&(min!= 0)) { min--; sec=59; } //**********************************// if((sec<0)&&(min==0)&&(flag0==1)) //洗衣结束 { flag0=4; out(); } //**********************************// if((sec<0)&&(min==0)&&(flag0==2)) //泡衣结束 { switch(flag3) { case1:flag0=4;out();break; case2:flag0=4;out();break; case3:flag0=4;out();break; default:err=1;led_wring = 0; } } //**********************************// if((sec<0)&&(min==0)&&(flag0==4)) //出水结束 { switch(flag2) { case1:flag0=0;in();break; case2:flag0=0;in();break; case3:flag0=0;in();break; case4:flag0=3;xx();break; default:err=1;led_wring=0; } } //***********************************// if((sec<0)&&(min==0)&&(flag0==3)) { sec=0; over(); } }
|