Hi, I am using a PIC16F628 for my project connected to a PIR sensor to detect movement. However, a square wave was detected which I suspect was from the mains as it has 50Hz frequency. Using a comparator, the signal do change when there are movements detected. I've tried many ways but i still can't eliminate the squarewave.

I am using PICBasic Pro to program the PIC. How can I write the program such that the PIC will give a low when the waveform is square (combination of high and low signals) and will give a high when there are movements (change in frequency and change in signal)?

Thanks.