loading

In this tutorial, we are going to use a Light Dependant Resistor (LDR) to build a simple light sensor.

Step 1: Wire Up Your Arduino

The first step is to wire up your Arduino.

For this we are going to need a resistor. The exactly value of resistor doesn't really matter, it will just alter the range of values that you get out of the light sensor. We are going to use a 6.5k resistor.

Insert one end of the resistor into one of the GND pins on the Arduino

Insert a yellow wire into analog pin 5 (as shown in the photo)

Insert a red wire into the 3.3v power pin (as shown in the photo)

Note: we could have used the 5v pin, but we might want to use that for something else later

Step 2: Wire Up Your Light Sensor (LDR)

Next we need to wire up the light sensor (LDR) as shown in the photo

To one leg of the sensor, attach the red power wire

To the other leg attach the yellow wire AND the resistor

Step 3: Write Your Code

The next step is to write some code to read the value of the light sensor.

Download the LightSensor.ino file and open it up in the Arduino application. You can tinker with it if you like, or just use it as it is. Once you are happy, upload it onto your Arduino.

Step 4: Connect Via Serial Monitor

Once the code has been successfully uploaded onto the Arduino, open up the "Serial Monitor" by clicking on the magnifying glass icon on the top right of the Arduino window. The Serial monitor should look like the above - make sure that "9600 baud" has been selected in the dropdown menu at the bottom of the window. You should be able to see a stream of numbers arriving in the serial monitor window - these are the light readings taken from the LDR sensor.

Step 5: Enjoy

If everything worked, you should be able to see that if you place your hand over the light sensor, the numbers in the serial monitor will drop; if you shine a light on the sensor, the numbers should increase. This is a measure of the current light level as detected by the sensor.

If you enjoyed this instructable, check out our other tutorials

If you love this kind of stuff, check out our degree

<p>Excelent! thanks, worked like a charm. I also modified the code a litle bit, adding 3 leds as a scale, lso when readings are bigger than 80 (I used 3.3k resistor), first led will turn on. If readings are bigger than 320, second led also lits and if the reading is bigger than 520, third led will lit too. <br>I think if this device would be used outsides, a resistor with a bigger resistance would be needed.</p>

About This Instructable

2,134views

28favorites

License:

Bio: Tutorials provided by BA/BSc (Hons) Digital Art and Technology at Plymouth University
More by Digital Art and Technology:Green space activity monitor Python Micro:bit Light Show Jumpstarting a Hot-glued Arduino 
Add instructable to: