新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > 单片机之旅——中断之流水灯

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

作者: 时间:2016-11-20 来源:网络 收藏

本文引用地址: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--);}}



关键词: 单片机中断流水

评论


技术专区

关闭
×

TI 在线会
2025年6月11日,与TI一起探索电动化汽车高效音频解决方案吧!