电路图:
代码如下:
#include
#include
sbit p1_0 = P1^0;
sbit p1_1 = P1^1;
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 LED_02() interrupt 2 using 1 {
delay ();
if (INT1 == 0) {
p1_1 = !p1_1;
while (INT1 == 0);
}
}
void main () {
p1_0 = 0;
p1_1 = 0;
EA = 1;
EX0 = 1;
EX1 = 1;
while(1);
}