Photoresistor Sensor

The Photoresistor Sensor module, also known as a Light Dependent Resistor (LDR), is an essential component for light sensing applications with Arduino. It can detect changes in light intensity and is widely used in projects like automatic lighting, light meters, and even DIY camera exposure control. In this step-by-step guide, we’ll show you how to set up the Photoresistor Sensor module with an Arduino and create projects that react to light levels.

Materials Needed:

  1. Arduino board (e.g., Arduino Uno, Arduino Nano)
  2. Photoresistor Sensor module
  3. 10K ohm resistor (for voltage divider configuration)
  4. Breadboard and jumper wires
  5. USB cable for Arduino
  6. Computer with the Arduino IDE installed (

Step 1: Wiring

Connect the Photoresistor Sensor module to the Arduino board as follows:

  • Connect one leg of the Photoresistor to the 5V pin on the Arduino.
  • Connect the other leg of the Photoresistor to the A0 analog input pin on the Arduino.
  • Place a 10K ohm resistor between the A0 pin and the GND pin on the Arduino.

Step 2: Arduino Code

const int photoresistorPin = A0; // Analog pin connected to the Photoresistor Sensor module

void setup() {
  Serial.begin(9600); // Initialize serial communication for debugging (optional)

void loop() {
  int lightValue = analogRead(photoresistorPin); // Read the analog value from the Photoresistor
  // Display the light value on the Serial Monitor
  Serial.print("Light Intensity: ");

  // Adjust the threshold value according to your environment
  int threshold = 500;

  if (lightValue < threshold) {
    // Low light detected! Add your desired action here.
    // For example, turn on a light, display a message, or trigger other events.

  delay(100); // Add a small delay to avoid rapid repeated detections

Open the Arduino IDE and create a new sketch. Then, enter the following code:

Step 3: Uploading the code

Connect your Arduino board to the computer using the USB cable and select the appropriate board and port from the Arduino IDE. Then, click the “Upload” button to upload the code to the Arduino.

Step 4: Observing the Light Intensity

Once the code is uploaded successfully, open the Serial Monitor from the Arduino IDE (Ctrl + Shift + M). You will see the analog values displayed on the Serial Monitor, representing the light intensity detected by the Photoresistor Sensor module. Cover the photoresistor with your hand or expose it to varying light conditions to observe changes in the light intensity values.

Step 5: Experiment and Interact

Now that the Photoresistor Sensor module is set up and responding to light, you can experiment with different threshold values to adjust its sensitivity to light. Use the light intensity readings to control various aspects of your project, such as turning on lights in a dark environment or reacting to changing lighting conditions.

Congratulations! You’ve successfully set up and used the Photoresistor Sensor module with Arduino. This versatile sensor allows you to detect changes in light levels, opening up a world of possibilities for creating light-sensitive projects and automating lighting systems. Have fun experimenting and incorporating the Photoresistor Sensor module into your Arduino projects to capture the essence of light!


Leave a reply

Your email address will not be published. Required fields are marked *



Log in with your credentials


Forgot your details?


Create Account