本文引用地址:http://m.butianyuan.cn/article/201611/318682.htm#include#includesbit K2 = P3^2;sbit K3 = P3^3;void delayms(unsigned int m);unsigned char aa = 0xfe;void main(){EA = 1;EX0 = 1;EX1 = 1;IT0 = 0;IT1 = 0;IP = 0xf1;P1 = 0xff;}/*低級的外部中斷2,負責按鈕1 的操作,即實現流水燈*/void button_1() interrupt 2{ if(K3 == 0){delayms(10);if(K3 == 0){while(1){ P1 = aa;aa = _crol_(aa,1);delayms(500);} }}}/*外部中斷0(最高級),負責打斷外部中斷 2*/void button_2() interrupt 0{if(K2 == 0){delayms(10);if(K2 == 0){while(1);}}}void delayms(unsigned int m){unsigned int i, j;for(i = m; i > 0; i--){for(j = 110; j > 0; j--);}}
評論