Control Light Room With Arduino and PIR Motion Sensor

29,984

36

13

Introduction: Control Light Room With Arduino and PIR Motion Sensor

About: For more project and tutorial visit my YouTube Channel Smart Technology

Today, we will see together how you can create an Arduino PIR motion sensor for your room in order to turn ON/OFF the light by detecting human movements.

PIR sensor:

The PIR sensor stands for Passive Infrared sensor. It is a low cost sensor which can detect the presence of Human beings or animals. There are two important materials present in the sensor one is the pyroelectric crystal which can detect the heat signatures from a living organism (humans/animals) and the other is a Fresnel lenses which can widen the range of the sensor. Also the PIR sensor modules provide us some options to adjust the working of the sensor as shown in above image.

Step 1: Supplies

Pick up the supplies required :

1. Arduino Uno

2. PIR motion sensor

3. Relay module

4. Some Wires

5. Lamp

Step 2: Connecting the Sensor and the Components

The PIR sensor has three pins :

1. VCC

2. GND

3. OUT

We have powered the PIR sensor using he 5V Rail of the Arduino. The output pin of the PIR Sensor is connected to the 4thdigital pin.Then, you have to wire the ''GND'' to the Arduino's ''GND''.

In this project, we use relay for controlling AC light because the Arduino cannot control high volt , but a relay can do this job, which is the sole design of it. so we are using relay as switch to control high power devices.

There are two ways to assembly the relay connection :

1. NC = Normally Closed Connection ( which I'm going to use ).

2. NO = Normally Open Connection.

so you have to wire the relay's ''OUT'' to the 8th digital pin of the arduino uno.Then the relay's ''GND'' to the arduino's ''GND'' and ''VCC'' to the ''VCC''.

NOTE: The wires are assembled as you see in the pictures above.

Step 3: Watch

Step 4: Programming

About the code :

int lamp = 8; // choose the pin for the RELAY
int inputPin = 4; // choose the input pin (for PIR sensor)

int val = 0; // variable for reading the pin status

void setup() {

pinMode(lamp, OUTPUT); // declare lamp as output

pinMode(inputPin, INPUT); // declare sensor as input

Serial.begin(9600);

}

void loop(){

val = digitalRead(inputPin); // read input value

Serial.println(val);

if( val== 1) {

digitalWrite(lamp,HIGH); // turn ON the lamp

} else {

digitalWrite(lamp,LOW); // turn OFF the lamp

}

}

Step 5: For Support

You can subscribe to the my YouTube channel for more tutorials and projects.

Subscribe for support. Thank you.
Go to my YouTube Channel -link https://goo.gl/EtQ2mp

Arduino Contest 2017

Participated in the
Arduino Contest 2017

1 Person Made This Project!

Recommendations

  • Mason Jar Speed Challenge

    Mason Jar Speed Challenge
  • Bikes Challenge

    Bikes Challenge
  • Remix Contest

    Remix Contest

13 Discussions

0
ArshadK21
ArshadK21

Question 1 year ago on Introduction

What is the rating of resistance or specification of diode

0
hackplague
hackplague

1 year ago

your project causes lots of false detection

0
kadirciftci
kadirciftci

1 year ago

Great Work Thx.
I have Used on my garage.

0
bbianciot
bbianciot

Question 2 years ago

Hello,

thank you to share with us this project.

I have a similar project. I would like to turn on a LED strip slowly with a kind of wave light intensity when someone comes near the sensor ? How can i do that. I have no experience but i'm willing to learn more.

Thank you for your help.

Bye

Baptiste

0
EmeraldS5
EmeraldS5

Answer 1 year ago

I want to learn how to do the same thing too!

Have you had any luck? :)

0
maxwega
maxwega

Question 2 years ago

your image shows a diode/resistor connected between the relay and Arduino on the breadboard, but you have not mentioned about it in the article nor in the supply list. So just asking, what is it and do we need it?

FFJ9IB3JAIJJTSN.LARGE.jpg
0
Smart Technology
Smart Technology

Answer 2 years ago

You don’t need it,Thanks for feedback

0
RajM85
RajM85

Reply 2 years ago

oh thank god..i think its a photoregister..am i right?

0
RajM85
RajM85

Answer 2 years ago

same question..

0
sidaqdeep1
sidaqdeep1

Question 2 years ago

WOULDNT AN nc(NORMALLY CLOSED CONNECTION BE ON ALL THE TIME AND turn off the light on motion?

0
FlyingDrMike
FlyingDrMike

Answer 2 years ago

Yes you are correct. Mike

0
AakashR10
AakashR10

Question 2 years ago on Step 4

hello i m beginner and dont know about programming much i have done connection properly and just pasted your program but its asking for initializers before pin mode

0
Smart Technology
Smart Technology

Answer 2 years ago

Sorry I don’t quite understand,into the arduino I have already initialized the lamp and the PIR Sensor