View previous topic :: View next topic |
Author |
Message |
chingB
Joined: 29 Dec 2003 Posts: 81
|
Door Access Application? |
Posted: Tue Mar 09, 2004 4:47 pm |
|
|
Hi,
I have access application and I put a micro-switch such that when the door is open it will closed. How can I monitor the door if it is open for 20seconds it sound an alarm?
Would it be possible to use interrupt?
Thanx |
|
|
asjad
Joined: 09 Mar 2004 Posts: 52 Location: Greater Manchester - UK
|
Door switch |
Posted: Tue Mar 09, 2004 4:53 pm |
|
|
You could use an external interrupt, which could start timer 0.
After say 10 seconds had elaspsed on the timer0. you could sound an alarm
Hope this helps!! _________________ Best Regards |
|
|
chingB
Joined: 29 Dec 2003 Posts: 81
|
Re: Door switch |
Posted: Tue Mar 09, 2004 5:10 pm |
|
|
asjad wrote: | You could use an external interrupt, which could start timer 0.
After say 10 seconds had elaspsed on the timer0. you could sound an alarm
Hope this helps!! |
Is this algorithm will do the job or maybe share some tips and suggestions to improve this code.
Code: |
#int_ext2
ext2_isr(){
flag=1;
doortmr=0;
int2if=0;
}
main(){
intedg2=1;
int2if=0;
enable_interrupts(int_ext2);
enbale_interrupts(global);
while(1){
if (bit_test(PORTA,2) && (doortmr>=20))
sound_alarm(ON);
if (!bit_test(PORTA,2) && flag){
sound_alarm(OFF); flag=0;
}
}
}
|
Thank u. |
|
|
|