• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Automatic Room Light Controller With Arduino and PIR Sensor

By Abhishek Ghosh March 2, 2024 7:55 am Updated on March 2, 2024

Automatic Room Light Controller With Arduino and PIR Sensor

Advertisement

In our earlier articles, we have explained What is a PIR Sensor, How it Works, and Arduino Light Sensor with LDR. In this project, we will set up an automatic light control system using Arduino. You can use Arduino UNO or any Arduino-compatible microcontroller board, such as ATtiny85.

If we use only a PIR Sensor to control the light then it will become ON even during the daytime. So we need a mechanism to keep it off during the daytime. For this reason, we need to add an LDR. This project is easy from the point of required programming skills.

 

Required Hardware to Build Automatic Room Light Controller

 

  1. Arduino Uno ( any other Arduino board will be just fine as long as it provides an Analogical pin ).
  2. PIR Motion Sensor
  3. LDR (Photoresistor)
  4. 10 KOhms resistor
  5. Relay module
  6. AC Lamp/Bulb etc
  7. Breadboard and jumper wires (optional)

 

Circuit Diagram For Automatic Room Light Controller

 

Connect one of the LDR legs to the VCC (5v of the Arduino). Connect the other LDR leg to the A0 pin Of Arduino and also to the resistor. Connect the (empty) resistor to the GND of the Arduino.

Advertisement

---

The PIR sensor has three pins :

  • VCC
  • GND
  • OUT

We have powered the PIR sensor using the 5V Rail of the Arduino. The output pin of the PIR Sensor is connected to the 2nd digital pin. You have to wire the ”GND” to the Arduino’s ”GND”.

In this project, we have used a relay for controlling AC light because the Arduino cannot control AC appliances directly, but a relay can do this job. There are two ways to assembly the relay connection :

NC = Normally Closed Connection (we have used this).

NO = Normally Open Connection.

You have to wire the relay’s ”OUT” to the 8th digital pin of the Arduino. Then the relay’s ”GND” to the Arduino’s ”GND” and ”VCC” to the ”VCC”.

Automatic Room Light Controller With Arduino and PIR Sensor

In the illustration, I have used an external DC power to complete the circuit. You have to use AC power and the bulb you want to control. You can run the simulator to check how it works:

This project is modified from this person’s project.

 

Required Sketch

 

Here is the sketch for the above project. You have to adjust the LightSensorVal < 600 for your project.

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
int LightSensorVal = 0;
int PIRSensorVal = 0;  
int RelayOutputVal = 0;  
 
void setup()
{
  pinMode(A0, INPUT);
  pinMode(2, INPUT);
  pinMode(8, OUTPUT);
  Serial.begin(9600);
 
}
 
void loop()
{
  LightSensorVal = analogRead(A0);
  PIRSensorVal = digitalRead(2);
  RelayOutputVal = 8;
  if (LightSensorVal < 600) {
    if (PIRSensorVal == HIGH) {
      digitalWrite(8, HIGH);
      delay(2000);
    } else {
      digitalWrite(8, LOW);
      delay(1000);
    }
  } else {
    digitalWrite(8, LOW);
    Serial.println(LightSensorVal);
    delay(300);
  }
}

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Automatic Room Light Controller With Arduino and PIR Sensor

  • Arduino and LED Bar Display : Circuit Diagram, Code

    Here is a Guide Explaining the Basics, Circuit Diagram, Code on Arduino and LED Bar Display. LED Bar Display is Actually Like Multiple LED.

  • LED Chaser Effect With PWM Using Arduino

    In our earlier article, We have discussed PWM and informed you that this PWD technology is used in particular for light-emitting diodes (LEDs), as they are often used as backlights on mobile phones or brake lights in newer motor vehicles. Our older article on Breathing LED also uses PWM. This was the sketch, LED is […]

  • Mini Christmas Light With Arduino (Very Easy)

    Here is a Mini Christmas Light With Arduino as Project Which Needs 3 Resisters and 3 LEDs, No External Power Supply. It Has 2 Blink Effects.

  • How to Control Multiple Relays With Single Arduino ESP32?

    Before How to Control Multiple Relays With Single Arduino ESP32 Testing, You Need to Learn How to Create Multiple MQTT Channels & Fetch Data.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy