HC-SR501 PIR Infrared Motion Sensor

Hello I do not know how to do this but trying to find a way to slowly brighten a led strip these are white leds 50/50 strip when the someone walks past this sensor the HC-SR501 PIR Infrared Motion Sensor i got it from ebay http://www.ebay.com/itm/HC-SR501-PIR-Infrared-Motion-Sensor-Detector-Arduino-PI-US-SELLER-/181155023969?pt=LH_DefaultDomain_0&hash=item2a2dae4c61 this is the sketch he/she gives with it

Simple Arduino Sketch to verify PIR:
/
/ Infrared HC-SR501 Proximity Sensor
/

int ledPin = 13; // LED pin for the LED
int inputPin = 2; // input pin
int pirState = LOW; //
int val = 0; // pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare output
pinMode(inputPin, INPUT); // declare input

Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input
if (val == HIGH) { // input HIGH
digitalWrite(ledPin, HIGH); // LED ON
if (pirState == LOW) {

// we have just turned on
Serial.println("Motion Detected!!");

// We only want to print on the output change, not state
pirState = HIGH;
}
} else {

digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){

// we have just turned of
Serial.println("Motion ended!");

// We only want to print on the output change, not state
pirState = LOW;
}
}
}

and after say like 10 minutes or so the led strip dims low in brightness say like 30% then then say 2 or 3 minutes after that it shuts off the led strip can someone please help me I'm putting this in my hallway soon..

val = digitalRead(inputPin); // read input

So, you have an input connected to the input pin. What the help kind of input?

int pirState = LOW; //

if (pirState == LOW) {

Well, of course it's going to be true.

What is the point of f**king around with pirState? Most people would actually read the state of a PIR sensor.

this is the sketch he/she gives with it

If that is really true, you should send it back, and demand your money back. The seller is too stupid to be allowed to use ebay.

yeah well i didn't make the sketch up there is a output pin to goes to the arduino digital pin and a vcc and a ground pin. all I'm trying to do is get it to come up slowly in PWM and when it's fully up stay on for 10 minutes and go back down in brightly slowly into it gets to 30% in brightness and then shut off or if someone keeps moving or doing something within that 10 minutes it still remains fully o into they leave. i just don't know how to do that. This is what i need help on.

there is a output pin to goes to the arduino digital pin and a vcc and a ground pin.

So, connect the Vcc pin to 5V (or 3.3.V), connect Gnd to Gnd, and connect the output pin to a digital pin. Then, digitalRead() that pin to determine if the PIR sensor is seeing motion.

Only when you can reliably detect motion would you add code to ramp up, stay up, and ramp down. Put all that code in a function called motionDetected() that you call when there is motion detected.

Hello PaulS yes i did that and got it coming up does show there is motion coming from about 10 ft away.

Hello PaulS yes i did that and got it coming up does show there is motion coming from about 10 ft away.

So, now add the code to fade the LED up, steady, and down.

i don't know have code to make it fade up and stay on for a long time like about 10 minutes. and then fade it back down to low light level. never made one of them before.

i don't know have code to make it fade up

Over what period of time?

for(int i=0; i<255; i++)
{
   analogWrite(somePin, i);
   delay(someTime);
}

The value in someTime will be 1/255 of the total time you want to take to fade up to full brightness.

and stay on for a long time like about 10 minutes.

delay(600000UL);

and then fade it back down to low light level.

for(int i=155; i>100; i--) // Fade to dim
{
    analogWrite(somePin, i);
   delay(someTime);
}
delay(180000UL); // Hold for 3 minutes
digitalWrite(somePin, LOW); // Then turn off