Type the following data into the main (before the infinite while loop) and write _Stop wherever you want your microcontroller to go into “low power mode”. If you want to wake the microcontroller to its normal “running mode”, you need to cause an interrupt of some sort. We will use Keyboard Interrupts (KBI) for the passive IR sensor and trip wires. Here is the code to set up the usage of “low power mode”:
// for low power mode: SOPT = SOPT_STOPE | SOPT_BKGDPE; // configure SOPT1 register, enable STOP instruction and BKGD SPMSC2 = 0; // stop3 mode selected
The PWM sensors will trip the KBI (Key Board Interrupt) and will count how many people are in the camera's area. If it counts to zero, the microcontroller will go into stop mode using the code above. If there are 0 people in the area, the stop function activates because there's no reason the microcontroller should be fully running when there is nobody around. Currently, it does not work; we are still debugging. We will update a working version as soon as possible.
'If statement' that runs if 0 people are present:
if(mode){
_Stop;
mode = 0;
}