Connect and Read Photoresistor with Arduino

Arduino tutorial that explains how to connect and read photoresistor with Arduino with physical hardware setup

Here we show how to Connect and Read Photoresistor with Arduino. Photoresistor or LDR(Light Dependent Resistor) is a light sensor. With this you can sense the amount of light in certain area where you wish to monitor the light amount. For example you might want to monitor light amount in your room and do something if the amount of light is less than certain value. In such case photoresistor can be used. Here we show how to connect and read photoresistor dependent voltage into arduino and display it on the arduino IDE serial monitor.

Basically this involves connecting the Photoresistor to one of the six analog pin. This is the similar to the earlier analogWrite function tutorial how to read analog signal with Arduino. By using the analogRead function we can then read in the varying voltage created by the photoresistor. The schematic is simple. We create a voltage divider circuit with two resistor- one is the Photoresistor and another is 10KOhm resistor. We connect the connection between these two resistor to analog pin like A0.

Circuit Diagram To Connect and Read Photoresistor with Arduino

The following schematic diagram shows how to connect and read Photoresistor with Arduino.

circuit diagram to Connect and Read Photoresistor with Arduino

As you can see we have connected the center of the resistor network to the A0 pin or the pin 0 of the arduino. The following picture shows the actual connection using breadboard.

Picture showing how to Connect and Read Photoresistor with Arduino UNO

Program Code to Read Photoresistor with Arduino

The program code for reading the Photoresistor created voltage at pin A0 of Arduino is as follows:

We have first simply setup the baud rate at 9600 for serial data transfer from arduino microcontroller to the PC via USB. Then in the loop function we continously read the analog voltage using analogRead() function. A0 was passed as argument to the analogRead() function to tell it which pin we will be using. Using a variable of type integer(int), we store the value read by the microcontroller. Then using the Serial.println() we print out the values to display it on PC.

We showed also how to use analogRead() to read analog signal with example that used potentiometer instead of photoresistor.

Video Demonstration showing Connection and Reading of Photoresistor produced voltage values with Arduino Serial Monitor

The following video demonstrates all this. Using an obstructive object, we limit the light falling on the photoresistor(LDR) and thereby we will see different values displayed in the serial monitor. This serial monitor is available in Arduino IDE top right corner.

This showed you how to connect and read changing voltage values created by photoresistor with Arduino. If you like it share it. For more tutorials see the Arduino Tutorials page.

Leave a Reply

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