#include
typedef unsigned int u16;
typedef unsigned char u8;
sbit key = P3^2;//
sbit led = P1^0;//
//延時(shí)函數(shù)
void delay(u16 num)
{
u16 x,y;
for (x=num; x>0; x--)
for (y=110; y>0; y--);
}
int main (void)
{
TCON |= 0x01;//配置寄存器
IE = 0x81;
while(1)
{
;
}
}
//設(shè)置中斷 入口地址0
void ext_int0 (void) interrupt 0
{
//延時(shí)10ms
delay(10);
//檢查key 還是為0 也就是真的被按下了
if (key == 0)
{
led = ~led;
}
while(!key);
}
/************************* Stay hungry, Stay foolish. @Rocky************************/