Introduction: Getting Started With Arduino - Light Sensor

About: Tutorials provided by BA/BSc (Hons) Digital Art and Technology at Plymouth University

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