hez_91
Newbie level 5
Hello,
I am working on a Anti-House Breaking System project which operates 24 hour/day surveillance.
I am planning to put it on sleep mode until the PIR sensor or Glass-Break sensor detects a break-in. How can this be done? (if possible)
I am aware of the 7 different operating modes but unsure of whether to use the Sleep or Idle modes and how to implement them.
I am also not sure of whether to use the watchdog timer or PIE interrupt to wake the PIC out of sleep mode.
Any help would be appreciated
I am working on a Anti-House Breaking System project which operates 24 hour/day surveillance.
I am planning to put it on sleep mode until the PIR sensor or Glass-Break sensor detects a break-in. How can this be done? (if possible)
I am aware of the 7 different operating modes but unsure of whether to use the Sleep or Idle modes and how to implement them.
I am also not sure of whether to use the watchdog timer or PIE interrupt to wake the PIC out of sleep mode.
Any help would be appreciated
Code:
#include <p18f4520.h>
#include <delays.h>
void main() {
//Initialisation of Analog and Digital and Port pins
ADCON1 = 0b00001111; // set as Digital I/O
TRISA = 0b00000011;
TRISB = 0b00000000;
while(1) {
if(PORTAbits.RA0=~PORTAbits.RA0) // Check for PIR Sensor
{
PORTB = 0b00000010; // Activate alarm
}
else
{
PORTB = 0b00000000;
}
if(PORTAbits.RA1=~PORTAbits.RA1) // Check for Glass-Break Sensor
{
PORTB = 0b00000010; // Activate alarm
}
else
{
PORTB = 0b00000000;
}
}
}