/* SERIAL_TERMINAL USED */ // ------ Libraries and Definitions ------ #include "simpletools.h" // ------ Global Variables and Objects ------ int pir; // ------ Function Declarations ------ int led2; int button; // ------ Main Program ------ int main() { // Wait 20 to 30 seconds for PIR to calibrate or"warm up" print("Wait about 5 seconds for PIR to calibrate..........."); print("\r"); pause(5000); term_cmd(CLS); // Once the PIR detects movement, it will send a HIGH or a value of 1 out from its OUTPUT pin pir = input(5); button = input(8); while (1){ if (pir == 1) { cog_run(led2, 128); print("Intruder Alert!"); print("\r"); freqout(4, 500, 250); term_cmd(CLS); pause(1000); high(2); pause(500); low(2); pause(500); } else if (button ==1) { print("Alarm deactivated\n"); freqout(4,500,0); low(2); pause(100); } } }