SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By makko
#74258
Hi Guys,

First off I have read this post and gotten nowhere.

At the minute I am running the code from the OP on that thread:
Code: Select all
// variables
int PIRpin = 2;  // PIR sensor's alarm pin ==> 10K ohm pull-up resistor ==> Digital Pin 2
int LEDpin = 11; // the LED pin to display output
int val = 0;     // the value of the PIR sensor

// setup
void setup()
{
 pinMode(PIRpin, INPUT);   // the PIR sensor alarm is input
 pinMode(LEDpin, OUTPUT);  // the LED is output
 
 digitalWrite(LEDpin, HIGH);  // turn on the LED 
 delay(1000);
 digitalWrite(LEDpin, LOW);  // turn on the LED 
 delay(1000);
 digitalWrite(LEDpin, HIGH);  // turn on the LED 
 delay(1000);
 digitalWrite(LEDpin, LOW);  // turn on the LED 

 
}

// code loop
void loop()
{
 val = digitalRead(PIRpin); // read PIR & set value to variable
    if (val == LOW)
    {
      digitalWrite(LEDpin, HIGH);  // turn on the LED
    }
    else 
    {
      digitalWrite(LEDpin, LOW);  // turn off the LED
      
    }
} 


void flash()
{
  digitalWrite(LEDpin, HIGH);  // turn on the LED
  delay(250);
  digitalWrite(LEDpin, LOW);  // turn on the LED
  delay(250);
  return;
}
Here is how I have wired up my PIR sensor..

Note: Thats Pin 2, 10KOhm and signal on the one track. 10K Ohm goes to the +5V Rail..

Image

My Problems:

When I power up the circuit + arduino everything the LED flashes real oddly..

The only way I can stabilise the circuit is by unplugging the PIR alarm(signal) wire for a few seconds.. Removing it and replacing it quickly won't work. It's like I have to let some capacitors drain on the PIR board..

My Question is simple. What am I doing wrong?? I must admit that I am pretty remedial when it comes to electronic circuits. I bought the arduino for the programming side of things really...

Any advice is greatly appreciated..

Thanks..
By zouze
#76855
I could not also make it work...I am experiencing the same thing...but I have interfaced it with an at89c2051...then I removed it and put a led at the alarm pin with 10k pull up resistor but still it does not work
here is the circuit I am using which I could not make to work properly:
Image
can you tell me what's wrong with it?
By riden
#76876
zouze, see my answer to the same question you posted on another thread.