📄 count.bak
字号:
/*********************
*********************/
#include <at89x51.h>
#define uchar unsigned char
#define uint unsigned int
/*******************************************/
sbit LED=P1^3;
sbit K_ZHI=P1^2;
sbit W1_K=P1^4;
sbit W2_K=P1^5;
sbit W3_K=P1^6;
bit w_a;
/*******************************************/
uint pan_data;
uint shu_ju;
uint pan_du;
uint aaa_b;
/*******************************************/
void clock_initial() reentrant using 0
{
TR0=0;
TH0=0Xff;
TL0=0Xff;
TR0=1;
}
/*******************************************/
void chu1_shi(void)
{
pan_du=6000;
/************************************************1****/
if((W1_K==1)&&(W2_K==1)&&(W3_K==1))
aaa_b=3;
else if((W1_K==0)&&(W2_K==1)&&(W3_K==1))
aaa_b=5;
else if((W1_K==1)&&(W2_K==0)&&(W3_K==1))
aaa_b=6;
else if((W1_K==0)&&(W2_K==0)&&(W3_K==1))
aaa_b=10;
else if((W1_K==1)&&(W2_K==1)&&(W3_K==0))
aaa_b=10;
else if((W1_K==0)&&(W2_K==1)&&(W3_K==0))
aaa_b=15;
else if((W1_K==1)&&(W2_K==0)&&(W3_K==0))
aaa_b=20;
else if((W1_K==0)&&(W2_K==0)&&(W3_K==0))
aaa_b=30;
}
/****************************************************/
void chu_shi(void)
{
shu_ju=8000;
pan_data=100000;
K_ZHI=1;
LED=1;
w_a=1;
clock_initial();
}
/*******************************************/
void delay(void)
{
uint i;
uint j;
for (i=1000;i>0;i--)
{
for (j=1000;j>0;j--)
{;}
}
}
/*******************************************/
void main(void)
{
P1=0XFF;
TMOD=0X02;
EA=1;
EX0=1;
IT0=1;
IP=0X00;
ET0=1;
chu1_shi();
chu_shi();
while(1)
{;}
}
/*******************************************/
void time0() interrupt 1 using 0
{
//clock_initial();
shu_ju--;
if(shu_ju==0)
{
chu_shi();
}
}
/********************************/
void exint0() interrupt 0 using 0
{
if(shu_ju>pan_du) //(75~80) ,7549,7548,7547, 7546,7544 闭和时7474
{
LED=0;
K_ZHI=0;
}
else
{
LED=1;
K_ZHI=1;
w_a=0;
}
shu_ju=8000;
if(w_a==1)
{
if(LED==0)
{
pan_du=pan_du+aaa_b;
if(pan_du>=8550)
{
chu1_shi();
}
}
}
if(w_a==0)
{
if(LED==0)
{
pan_data--;
if(pan_data==0)
{
K_ZHI=1;
LED=1;
//delay();
}
}
else
pan_data=100000;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -