Detect darkness Using Arduino and LDR Sensor

Detect the darkness with the help of Arduino board and LDR Sensor

In this project, Arduino and LDR Sensor turns on lights automatically,

when an LDR sensor detects darkness.

Requirements of hardware for this project:

  1. Arduino UNO board
  2. A USB cable for connecter Arduino UNO board
  3. LDR Sensor
  4. Jumper wires male to female
  5. LED light
Detect darkness Using Arduino and LDR Sensor

Requirements of software in this project:

  1. Arduino IDE (To program the Arduino board, we need to download the Arduino software.)

The Working principle the project:

The Arduino UNO board is programmed to send the data to the LDR sensor. LDR sensor detects the darkness. The LDR sensor sends the data Arduino UNO board. The code downloaded within the Arduino board verifies the received data and then it turns on or off the LED light.

Write a program for the Arduino IDE.                        

Full code show in below: 

int LDR = 0;     
 int LDRValue = 0;      
 int light_sensitivity = 500;    
  
 void setup()
   {
     Serial.begin(9600);          
     pinMode(13, OUTPUT);     
   }
  
 void loop()
   {
     LDRValue = analogRead(LDR);       
     Serial.println(LDRValue);       
     delay(50);        
  
     if (LDRValue < light_sensitivity) 
       {
         digitalWrite(13, HIGH);
       }
     else
       {
         digitalWrite(13, LOW); 

Save the program and compile the code, as shown in the following figure:

Detect darkness Using Arduino and LDR Sensor 1
Detect darkness Using Arduino and LDR Sensor 2

Connect your Arduino UNO board to your laptop or desktop computer through the Arduino UNO USB cable. Remove all other connections with the Arduino UNO board, such as the LDR Sensor and LED bulb. After that Upload the program to the Arduino UNO board. 

Detect darkness Using Arduino and LDR Sensor 3

Before uploading the code to the Arduino UNO board make sure that your Arduino serial port is selected. Otherwise, an error message "Serial port not selected" is displayed on the screen.

To select your serial port in your laptop or desktop:

Open Device Manager -> Ports ->Arduino Uno, and then upload your code.

Detect darkness Using Arduino and LDR Sensor 4

After uploading the program in the Arduino UNO board. Connect all modules with the Arduino UNO board, such as the LDR Sensor and LED bulb. The following image shows the Digital circuit Diagram.

Detect darkness Using Arduino and LDR Sensor 5

When the LDR Sensor enters in the dark area, then LED light turns on. When the LDR sensor does not enters in the dark area, then LED light turns "off", as shown in the following image.

Detect darkness Using Arduino and LDR Sensor 6
Detect darkness Using Arduino and LDR Sensor 7
Detect darkness Using Arduino and LDR Sensor 8

Related Topics

Detect darkness Using Arduino and LDR Sensor

Detect the darkness with the help of Arduino board and LDR Sensor In this project, Arduino and LDR Sensor turns on lights automatically, when an LDR sensor detects darkness. Requirements of hardware...

2 minutes read.

Advantages and Disadvantages of IoT

Advantages of IoT Applications Security: You can control your home through the mobile phones. It provides personal protection. Stay connected: You can connect virtually to your family. Efficient usage of electricity:  You can use...

2 minutes read.

IoT Ecosystem

The following figure shows the seven-layer model of the IoT Ecosystem. The first layer represents the market or application domain that includes smart grid, connected home, smart health, or smart cities, etc.The second layer consists...

1 minute read.

5G

The next generation of mobile networks is a new global wireless standard after 1G, 2G, 3G, and 4G networks. It enables a new network to connect virtually everyone, including machines,...

5 minutes read.

Internet of Things

The Internet of Things is a network of objects embedded with sensors, software, and other technologies for connecting and exchanging data with other devices and systems over the internet. These devices...

5 minutes read.

Arduino UNO Home Automation

Build a Bluetooth controlled Home Automation Setup Using Arduino UNO board and Relay module Do you want to automate your home? Have you ever wanted to control your home appliances by swipe the screen...

4 minutes read.

What is an IoT Device?

A device in which a sensor is connected and able to transfer data from one device to another over the internet is called an IoT device. IoT devices consist of software, wireless sensors, actuators,...

1 minute read.

Contiki OS

Contiki OS Contiki is an open-source operating system (OS) that works on small, low-power microcontrollers. It allows the development of applications. The application allows efficient use of hardware while providing standardized low-power wireless communication...

2 minutes read.

Skills required for an IoT Developer

"Internet of Things" is about communication between software and devices. An IoT development team should be essentially large, and developers are divided into different areas according to their respective work. Some of these...

1 minute read.

IoT GE Predix

The GE Predix stands for the General Electric Predix. GE Predix is a software platform that collects data from industrial instruments. It provides a cloud-based PaaS (platform as a service)...

1 minute read.

Arduino UNO Bluetooth LED Controls

How to Build a Bluetooth controlled LED light Setup Using Arduino UNO board: Let's build an IoT project using Arduino UNO and the Bluetooth module HC-05 to control an LED. In this project,...

2 minutes read.

Download and Install Arduino in Windows

Download and Install Arduino in Windows Step 1. Download  IDE from https://www.arduino.cc/en/Main/Software. Step 2. Scroll down the page and click on Windows app link, as shown in the following figure. Step 3. Click on the...

1 minute read.

Session Layer Protocols

1) MQTT MQTT stands for Message Queue Telemetry Transport. It was introduced by IBM in 1999 and standardized by OASIS in 2013. It is used for remote monitoring in IoT. Its...

2 minutes read.

IoT Hardware

IoT hardware includes a wide range of devices, such as routing devices, bridges, sensors, etc. These IoT devices support key tasks and functions such as system activation, security, action specifications, communication, and detection...

2 minutes read.

IoT Protocols

IoT Protocols A protocol is a set of basic rules that allow electronic devices to communicate with each other. These instructions include the types of data that can be sent, the...

1 minute read.

Arduino UNO Board with PIR Motion Sensor

Arduino UNO Board with PIR Motion Sensor In this project, we will create a simple circuit with an Arduino UNO and PIR motion sensor detects movement. An LED light up when the movement...

2 minutes read.

Applications of IoT

Smart Home: A smart home encapsulates the connectivity inside our homes. It includes home appliances, smoke detectors, windows, light bulbs, door locks, etc. Smart City: A Smart City is a technically advanced...

2 minutes read.

Arduino UNO Distance Project

Ultrasonic Sensor HC-SR04 and Arduino to distance calculation using Processing App: Let's build an IoT project using Ultrasonic HC-SR04 Sensor and Arduino UNO to calculate the distance between the Ultra Sonic HC-SR04 device and...

2 minutes read.

Challenges of IoT

Challenges of IoT There are two categories of challenges to overcome for the IoT organization to grow. It is accepted by all the technologies not only for IoT. Two significant challenges in IoT: Technological...

3 minutes read.

IoT Architecture

Our approach to the IoT architecture is reflected in the IoT architecture diagram that presents the diagram of an IoT system and explains how it is connected to store, collect,...

2 minutes read.