您的位置 首页 芯闻

单片机之旅——中止之流水灯

#includereg52.h>#includeintrins.h>sbitK2=P3^2;sbitK3=P3^3;voiddelayms(unsignedintm);unsignedch

#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--);}}


声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/news/xinwen/263880.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部