电路图:
功用:按键开关灯。
代码如下:
#include
#include
sbit p1_0 = P1^0;
void delay (void) {
int a = 500;
while(a–) _nop_();
}
void LED_01() interrupt 0 using 1 {
delay();
if (INT0 == 0) {
p1_0 = !p1_0;
while (INT0 == 0);
}
}
void main () {
p1_0 = 0;
EA = 1;
EX0 = 1;
while(1);
}