
本文引用地址:https://www.eepw.com.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--);}}
评论