当前位置:首页 > 单片机 > 单片机
[导读]没有中断时以流水灯显示,外中断0使左右4个LED交替闪烁,外中断1使LED闪亮,#includeunsigned char code design[]={0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x00};void Delay(unsigned int i){ unsigned int j;

没有中断时以流水灯显示,外中断0使左右4个LED交替闪烁,外中断1使LED闪亮,

#include

unsigned char code design[]={0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x00};

void Delay(unsigned int i){

unsigned int j;

for(;i>0;i--)

for(j=0;j<125;j++);

}

void main(){

unsigned char i;

EA=1;

EX0=1;

EX1=1;

IT0=1; //脉冲触发方式

IT1=0; //使用电平触发

PX0=0;

PX1=0;

while(1){

for(i=0;i<=9;i++){

P1=design[i];

Delay(500);

}

}

while(1);

}

void int0_int(void) interrupt 0{

EX0=0;

P1=0xf0;

Delay(5000);

P1=0x0f;

Delay(5000);

EX0=1;

}

void int1_int(void) interrupt 2{

EX1=0;

P1=0x00;

Delay(5000);

P1=0xff;

Delay(5000);

EX1=1;

}


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭