Detect darkness Using Arduino and LDR Sensor

Facebooktwitterredditpinterestlinkedinmailby feather

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: 

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
Facebooktwitterredditpinterestlinkedinmailby feather