Week 2: Implementation of LDR in a circuit

In the second lecture of Physical Computing we were introduced to a new component a Light Dependent Resistor (LDR). “An LDR is a component that has a variable resistance that changes with the light intensity that falls upon it. This allows them to be used in light sensing circuits.”

(How an LDR (Light Dependent Resistor) Works, 2014).

A number of different applications for an LDR include:

Lighting:

An LDR can be used to automatically turn lights on and off at certain light levels. An example of this could be street lamps or a garden light.

Camera Shutter Control:

Another example of how an LDR is used could be to control a camera’s shutter control. The LDR would be used to measure the light intensity which then adjusts the camera shutter speed.

Arduino:

To see how the LDR worked using our Arduino, we set up a circuit which allowed us to measure the output of the LDR.

To measure this we set up the following circuit on our breadboard and Arduino:

Source: https://www.arduino.cc/en/tutorial/AnalogInput

This image of the Arduino shows a visual representation of the circuit I made during this weeks lecture (further down the page) the second image is a circuit diagram for this circuit. When the light level decreases, the resistance of the LDR increases. As this resistance increases in relation to the other Resistor, which has a fixed resistance (5k), it causes the voltage to drop across the LDR to also increase.

Circuit Diagram:

Code:

int secnsorPin = A0; //select the input pin for the LDR
int secsorValue = 0; // variable to store the value coming from the sensor
void setup(){
Serial.begin(9600); //sets serial port for communication
}
void loop(){
sensorVlue = analogRead(sensorPin); ..read the value from the sensor
Serial.println(sensorValue);
delay(100);
}

Image of Circuit:

Once I completed, this circuit I managed to add an LED to the circuit which is controlled by the LDR. To do this I added a second resistor to control the voltage to the LED and then wired the LED into the Arduino to complete the circuit.

I then coded the LED into the original code to allow the LED to turn on if the sensorValue was lower than a particular value and turn off if the ‘sensorValue’ was higher than a specified value. This resulted in the LED turning on if the LDR was covered and off if the LDR was exposed to light.

Photo of Circuit:

Code:

int secnsorPin = A0; //select the input pin for the LDR
int secsorValue = 0; // variable to store the value coming from the sensor
void setup(){
Serial.begin(9600); //sets serial port for communication
pinMode(9, OUTPUT);
}
void loop(){
sensorVlue = analogRead(sensorPin); ..read the value from the sensor
Serial.println(sensorValue);
delay(100);
if (sensorValue <= 20){ digitalWrite(9, HIGH); }else if(sensorValue >= 21){
digitalWrite(9, LOW);
}
}

Further Learning:

Before the next session of Physical Computing, I am planning to research how an LDR component can be used in different circuits. This will hopefully give me some further inspiration for creating my final project in Physical Computing.

References:

How an LDR (Light Dependent Resistor) Works (2014) Available at: https://www.kitronik.co.uk/blog/how-an-ldr-light-dependent-resistor-works/ (Accessed: 18/02/19)

Leave a comment