gaurav_sharma132
Member level 1
Hello
I'm making project on Home automation along with varying light intensity and fan speed using Philips TV remote.
There is little problem at software side I'm facing. As at one pin INT0 I have switch and at other INT1 i have ZVS(Zero voltage signal). Both interrupt routines are are edge triggered. What I want is at every time the switch is pressed the delay is going to be inc by 1ms. I have made delay routine using for loop. So that speed of fan or light intensity can be varied.
As a single variable is used inside both interrupt routine so I have declare the global variable above main but problem is that whenever I press switch the value is not updating in the function call inside INT1 routine.
#include<reg51.h>
#include<intrins.h>
sbit fan1=P1^3;
unsigned char x; //global variable decleration
void delay(unsigned int time)
{
unsigned int l,m;
for(l=0;l<time;l++)
for(m=0;m<112;m++);
}
void delay1(unsigned int time)
{
unsigned int l,m;
for(l=0;l<time;l++)
for(m=0;m<40;m++);
}
void ExtInt0() interrupt 0 //switch
{
x=x+1;
}
void ExtInt1() interrupt 2 //ZVS
{
delay(x); //this variable x is not incrementing at all
fan1=1;
delay1(1);
fan1=0;
}
void main()
{
IE=0x85;
IT1=1;
IT0=1;
while(1)
{
}
}
Whats is the problem? Please help me.
I'm making project on Home automation along with varying light intensity and fan speed using Philips TV remote.
There is little problem at software side I'm facing. As at one pin INT0 I have switch and at other INT1 i have ZVS(Zero voltage signal). Both interrupt routines are are edge triggered. What I want is at every time the switch is pressed the delay is going to be inc by 1ms. I have made delay routine using for loop. So that speed of fan or light intensity can be varied.
As a single variable is used inside both interrupt routine so I have declare the global variable above main but problem is that whenever I press switch the value is not updating in the function call inside INT1 routine.
#include<reg51.h>
#include<intrins.h>
sbit fan1=P1^3;
unsigned char x; //global variable decleration
void delay(unsigned int time)
{
unsigned int l,m;
for(l=0;l<time;l++)
for(m=0;m<112;m++);
}
void delay1(unsigned int time)
{
unsigned int l,m;
for(l=0;l<time;l++)
for(m=0;m<40;m++);
}
void ExtInt0() interrupt 0 //switch
{
x=x+1;
}
void ExtInt1() interrupt 2 //ZVS
{
delay(x); //this variable x is not incrementing at all
fan1=1;
delay1(1);
fan1=0;
}
void main()
{
IE=0x85;
IT1=1;
IT0=1;
while(1)
{
}
}
Whats is the problem? Please help me.