stc89c52ΪʲôִֻÐÐÒ»´ÎÍⲿÖжϵijÌÐò£¬Ö÷º¯ÊýµÄ¿ª¹ØÔٴΰ´Ï£¬ÍⲿÖжϺ¯Êýû·´Ó¦
ʱ¼ä£º10-02
ÕûÀí£º3721RD
µã»÷£º
#include <reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit deng=P3^7;
sbit jinshu=P1^4;
void delay_1ms(unsigned int a)
{
unsigned int i;
while( a-- £¡= 0){
for(i = 0; i < 552; i++);
}
}
void ini_int1(void)
{
EA=1;
EX1=0; //¿ªÆôÍⲿÖÐ¶Ï 0
IT1=0;
//TCON=0x04;
}
void Int1() interrupt 2 using 2 //ʹÓÃÍⲿÖжÏ1,¼Ä´æÆ÷×é3
{ EX1=0;//¹Ø±ÕÖжÏ
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
}
void main(void)
{
ini_int1();
while(1)
{ deng=0;
if(jinshu==0)
{
delay_1ms(10);
if(jinshu==0)
{
EX1=1; //¿ª¹Ø°´Ï´ò¿ªÖжÏ
}
}
}
}
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit deng=P3^7;
sbit jinshu=P1^4;
void delay_1ms(unsigned int a)
{
unsigned int i;
while( a-- £¡= 0){
for(i = 0; i < 552; i++);
}
}
void ini_int1(void)
{
EA=1;
EX1=0; //¿ªÆôÍⲿÖÐ¶Ï 0
IT1=0;
//TCON=0x04;
}
void Int1() interrupt 2 using 2 //ʹÓÃÍⲿÖжÏ1,¼Ä´æÆ÷×é3
{ EX1=0;//¹Ø±ÕÖжÏ
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
deng=1;
delay_1ms(1000);
deng=0;
delay_1ms(1000);
}
void main(void)
{
ini_int1();
while(1)
{ deng=0;
if(jinshu==0)
{
delay_1ms(10);
if(jinshu==0)
{
EX1=1; //¿ª¹Ø°´Ï´ò¿ªÖжÏ
}
}
}
}
ÍⲿÖжÏÊÇÒÀ¿¿ÖжÏÒý½ÅÉϵĵçƽ±ä»¯À´½øÈëÖжϵģ¬Èç¹ûµçƽûÓб仯£¬ÊÇû·¨½øÈëÖжϵģ¬ÄãÕâÑùʹÓÃÍⲿÖжÏÊÇ´íÎóµÄ£¬´ó¸ÅÄãÊÇÏë²úÉúµÆÉÁ˸µÄЧ¹û£¬ÕâÖÖÇé¿öÓ¦¸ÃʹÓö¨Ê±Æ÷Öжϡ£
³ÌÐòÀïÃæµÄÉÁ˸ֻÊÇΪÁË·½±ã¹Û²ì£¬ÎÒÊÇÏëÍⲿÒý½Å±ä»¯½øÈëÍⲿÖжϣ¬ÎҾͰÑÖжϹØÁËEX1=0£¬Ö´ÐÐÍêÉÁ˸³ÌÐòºó£¬ÔÚÆô¶¯¿ª¹ØjinshuûÓа´ÏÂ֮ǰ£¬Òý½Å±ä»¯ÊDz»ÄܲúÉúÖжϵģ¬Ö»ÓÐÆô¶¯¿ª¹Ø°´Ï£¬ÖØдò¿ªÍⲿÖжÏEX1=1ºó£¬ÍⲿÒý½Å±ä»¯²ÅÄܲúÉúÖжϣ¬¿ÉÊǵ±µÚÒ»´Î½øÈëÍⲿÖжϣ¬ÎÒ°ÑEX1=0£¬ºó£¬°´ÏÂÆô¶¯¿ª¹Ø´ò¿ªEX1=1ºó£¬ÍⲿÒý½Å±ä»¯£¬Ò²²»ÔÙ½øÈëÍⲿÖжϺ¯ÊýÖ´ÐÐÉÁ˸³ÌÐò