Hi I have found this code in another thread, however the only problem I am encountering (which im assuming is going to be a 'duh' moment when someone responds) but how do i set up my PIR? I am using an UNO... i had the 5v lead of PIR in 5v of arduino, ground in GND and the 'OUT' lead of PIR in digital pin 2... but I get nothing at all?
thanks...
const int firstLED = 3;Â Â Â // pin for the LED
const int inputPin = 2;Â Â Â // input pin for the PIR sensor
int PIRstate;Â Â Â Â Â Â Â // variable to hold the last PIR state
int val;Â Â Â Â Â Â Â Â Â Â // variable for reading the pin status
void setup() {
 pinMode(inputPin, INPUT);       //declare PIR as input
 PIRstate = digitalRead(inputPin);   //assign PIR state to PIRstate
}
void loop() {
 val = digitalRead(inputPin);   // read input value
 if (val != PIRstate)           // check if the input has changed
 {
  if(val == HIGH){Â
   analogWrite(firstLED, 255);
  }
  else{
   for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
    // sets the value (range from 0 to 255):
    analogWrite(firstLED, fadeValue);   Â
    // wait for 30 milliseconds to see the dimming effect Â
    delay(30);             Â
   }
  }
 }
 PIRstate = val;        // save the new state to the variable
}