PIR Sensor HC-SR505 won't work

I can’t for the life of me get this D@#N sensor to work. I hook up the sensor just like it is show in this tutorial since it’s basically the same sensor with the same pinout. Here is my simple code:

int MotionSensor  = D0;      // Motion sensor to detect Dog                                      
int Motion;

void setup() {
pinMode(MotionSensor, INPUT_PULLUP);
Particle.variable("Motionsensor", &Motion, INT);

void loop() {
Motion = digitalRead(MotionSensor);


The sensor will go HIGH when it sees movement and then will go LOW 8 seconds after the last motion. Then it will stay low for 8 seconds and then go HIGH again for NO reason. I’ve gone as far as putting it in a box and not touching it just to make sure I’m not mistakenly triggering it and it still does the same thing. I’ve tried hooking it up to different pins and 5V instead of 3V3 but this does nothing and stays LOW regardless of movement. I know the sensor is in proper working condition because I can hook it up to a battery and LED with resistor on signal pin and get it to blink. What could I be doing wrong?


How about INPUT_PULLDOWN or just INPUT (as in the original code of the tutorial)?


Thanks for the reply. Last night I tried INPUT_PULLDOWN, INPUT, and INPUT_PULLUP with no success. It still does the same thing oscillating between high and low signals for no reason. I’ll be more than happy to mail you one or you can pick one up for about $2 off ebay.