I am having a similar problem. I'm using a pir sensor, checking for motion every 2 seconds, and when motion is detected I want to turn on some 12V LED lights and hold them on for a time (15 seconds). After the delay the sensor goes back to checking for motion. I have tried a relay to switch the 12V LEDs and when the relay is connected to Pin 13 the pir keeps coming back on immediately after the 15 second delay. (It goes off and then pops back on again) I have also tried using a MOSFET transistor to switch the LEDs. If I don't connect pin 13 to the relay or the MOSFET the sketch works perfectly, but as soon as I hook up the lights the pir keeps tripping whether there is motion or not.
Motion.txt (887 Bytes)