?? test.c
字號(hào):
#include <reg51.h>
#include"intrins.h"
sbit fan=P3^7;
sbit pressed=P3^5;
unsigned char fan_open=0;
unsigned char int_time=0;
unsigned char table[9]={20,30,40,50,60,70,80,90,100};
unsigned char p=0;
//中斷子程序
void ext0(void) interrupt 0
{
int_time++;
fan_open--;
if(fan_open==0) {fan_open=table[p];fan=0;}
if(int_time>=100) {fan_open=table[p];int_time=0;fan=1;}
}
//延時(shí)子程序
void delay(void)
{
unsigned int i,j;
for(i=0;i<10000;i++)
for(j=0;j<4;j++)
_nop_();
}
/************主 程序*************/
void main(void)
{
fan_open=table[p];
IT0=1;
EA=1;
EX0=1;
fan=1;
while(1)
{
if(pressed==0) {if(p>=9) p=0;p++;}
delay();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -