PIR Sensor and Arduino

here is my project instrument List

  1. Arduino Nano
  2. 9 LED
  3. PIR Motion Sensor
  4. 5V relay
  5. 220V AC Light Bulb

**I Want to turn on the 220V AC Light bulb for one hour when PIR Motion Sensor Detects any Human , while the bulb is turn on for one hour i want to blink that 9 LED also high low high low for one HOUR **

int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7= 8;
int led8= 9;
int led9 = 10;

int relay = 13;

int pin = A2;

int value = 0;
int pirState = LOW;
const unsigned long even_1 = 43000;

void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);

pinMode(relay, OUTPUT);

pinMode(pin, INPUT);
Serial.begin(9600);
}

void loop() {

value = digitalRead(pin);

if (value == HIGH)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
digitalWrite(led9, HIGH);

digitalWrite(relay, LOW);

delay(1800000);

}

if (value == LOW)
{
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led4, LOW);
delay(100);
digitalWrite(led5, HIGH);
delay(100);
digitalWrite(led5, LOW);
delay(100);
digitalWrite(led6, HIGH);
delay(100);
digitalWrite(led6, LOW);
delay(100);
digitalWrite(led7, HIGH);
delay(100);
digitalWrite(led7, LOW);
delay(100);
digitalWrite(led8, HIGH);
delay(100);
digitalWrite(led8, LOW);
delay(100);
digitalWrite(led9, HIGH);
delay(100);
digitalWrite(led9, LOW);
delay(100);

digitalWrite(relay, HIGH);

}

}

Do you have a question?

Is your post the start of a tutorial?

Please read How to get the best out of this forum and follow the suggestions.

The Question is , I want to blink on and off LED's for one hour as the same time the AC bulb is turn on.

That isn't a question.

And you failed to answer my second question.

@faisalzed, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code. See How to get the best out of this forum which contains other useful tips as well.

2 Likes