#include "reg51.h" #include"intrins.h " sbit led_yello_power=P1^0; sbit led_green_heat=P3^7; sbit led_red_auto=P1^4; sbit beep=P3^5; sbit heat=P1^5; sbit run=P1^7;
sbit func_select=P1^6; sbit start=P1^2; unsigned char n=0; unsigned char func_flag=0; unsigned char stop=1; void delay(int n) {int j,k; for(k=0;k<n;k++) {for(j=0;j<55;j++); } }
void ok1(void) { while(func_select==1&&start==1) {beep=1; led_red_auto=1; delay(250); beep=0; led_red_auto=0; delay(500); } }
void ok2(void) { while(func_select==1&&start==1) {beep=1; led_green_heat=1; delay(250); beep=0; led_green_heat=0; delay(500); } } void init(void) { P1=0x5f; P3=0xff; delay(100); P1=0x54; P3=0x0f; func_flag=0; stop=1;
}
void ex0_1(void) interrupt 0 {n++; EX0=0; heat=0; delay(1000); EX0=1;
}
void func_heat(void) {while(n<3)heat=1; heat=0; }
void func_auto(void) {unsigned char i; for(i=0;i<5;i++) {run=1; delay(18000); run=0; delay(8000); } }
void scan_key(void) {if(func_select==0||start==0) { delay(200); if(func_select==0||start==0) { if(func_select==0) {while(func_select==0); if(func_flag==0) { func_flag=1; led_green_heat=0; led_red_auto=1; } else { func_flag=0; led_green_heat=1; led_red_auto=0; } } else if ( start==0) { while(start==0); if(stop==0)stop=1; else stop=0; } } } }
void main(void)
{init(); IT0=1; EX0=1; EA=1;
while(1) { scan_key(); while(stop==1)scan_key(); if(stop==0&&func_flag==0) { func_auto(); func_heat(); ok1(); } else if(stop==0&&func_flag==1) {func_heat(); ok2(); }
init();
}
} |