Introduction: How to Use a Photoresistor (or Photocell) - Arduino Tutorial

A photoresistor or photocell is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity. A photoresistor can be applied in light-sensitive detector circuits, and light- and dark-activated switching circuits. It's also called light-dependent resistor (LDR).

In this tutorial you will learn how to use a photoresistor with and without arduino uno.

So, let's get started!

Step 1: How to Use Photoresistor

Let's see how a photoresistor react in light. Build the circuit above and notice how led brightness change.

The resistance value becomes smaller when there is much light in the room. So in the dark the led remains off because the resistance has become very big.

The Arduino will help us to reverse this situation, let's see how in next step.

Step 2: The Circuit

You will need:

  • Arduino uno
  • Breadboard
  • LED
  • 220 Ohm & 10 KOhm resistors
  • Photoresistror

Step 3: The Code

Here's the 'led & photoresistor' code, embedded using codebender!

How it works:

  • Read analog value from photoresistor/photocell
    -> value=analogRead(pResistor)
  • Check if value is bigger than e.g. 25
  • Send command to turn on/off the led

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board!

You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code.

For example, try to change "25" value and see how it changes the program.

Step 4: Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use a photoresistor!

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button!


wenden_jason made it!(author)2015-09-13

I thought the proper name for these was an LDR (light dependant resistor)

sara33 made it!(author)2015-08-26

How would I code this so I could see the output's power? I'm using analogRead and serial.print, but the analog read keeps saying 1023, even when I put my hand over the photoresister.

zbot473 made it!(author)2015-08-21

Can you just read the Photoresistor output

zbot473 made it!(author)2015-08-21

I m an instructable noob

How do you do that box in the intro page

gaganvajra made it!(author)2015-06-26

hi im quite new to arduino and i have a question about voice recognition module v3.1

.can anybody help me please....

i need to know how to use the commands and what r the commands.......

codebender_cc made it!(author)2015-08-15

Hi! Just stay online and make sure that you have pressed the "Follow" button.

I will write a "How to" tutorial with this in the future.

tinker2015 made it!(author)2015-06-22

hi im quite new to arduino and i have a question about photocells i was hoping you could help me with i need to stop/pause a sketch using a photocell when its detected a change in light how would i do this any help at all will be appreciated

codebender_cc made it!(author)2015-08-15

Hi! That is quite simple. Just use the part of code with " if " conditions.

About This Instructable




Bio: Arduino Tutorials by Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: