Introduction

A Light Dependent Resistor (LDR) or a photo resistor is a resistor whose resistance changes as the intensity of light falling on it changes. As the intensity increases, the resistance decreases, and vice-versa. This property makes them useful while making light sensing, or light dependent circuits.

How to interface the LDR

Example: Controlling Pin 13 LED using an LDR

In this example we’re going to use an LDR to turn ON the pin 13 LED on evive. If the intensity of light is more than a value predefined, the LED will turn ON; otherwise, it will remain OFF.

evive Notes Icon
The resistance of the LDR changes with change in light falling on it. This in turn changes the voltage across the terminals of the LDR. It is this voltage that will be used to set the value, also known as a reference.

Wiring

Follow the steps below to connect the LDR to evive:

  1. Take a red male-to-male jumper wire and connect one of its free ends to the 5V pin of evive in the top-left corner, as shown in the figure below. Take its second end and insert it in the 9th hole from the right of the 1st row of the breadboard.
  2. Take the LDR and insert one of its legs in the 9th hole from the right of the 5th row of the breadboard. Insert its second leg in the 6th hole from the right of the same row.
  3. Take the 10kΩ resistor and insert one of its legs in the 6th hole from the right of the 3rd row of the breadboard. Insert its second leg in the 2nd hole of the same row.
  4. Now, take an orange male-to-male jumper wire and insert one of its ends in the 6th hole of the 2nd row of the breadboard. Take its second end and connect it to the A0 analog pin, right above the breadboard, as shown in the figure below.
  5. Take a black male-to-male jumper wire and connect one of its free ends to the GND pin of evive in the top-left corner, as shown in the figure below. Take its second end and insert it in the 2nd hole from the right of the 1st row of the breadboard.

Below is the complete circuit diagram:

Scratch Script

Follow the steps below to write the script:

evive Tips and Tricks
If you’re working with evive in Scratch mode for the first time, or have uploaded the Arduino firmware previously, first upload the Scratch firmware; you can find the procedure to do the same here
  1. Connect evive to your laptop/PC, and select the appropriate port.
  2. Open mBlock; if already open and working on a project, save that project. Then, click on New.
  3. Go to the Events palette and drag and drop the when ‘flag’ clicked block.
  4. From the Control palette, drag and drop the forever block below the when ‘flag’ clicked block.
  5. Go to the Data&Blocks palette and create a variable LDR. Then, drag and drop the set () to () block inside the forever block.
  6. Go to the Robots palette and drag and drop the Read analog pin () block inside the second space of the set () to () block. Select A0 from the drop-down menu.
  7. Go to the Control palette and drag and drop the if-else block below the set () to () block. Go to the Operators palette and drag and drop the () < () block inside the diamond shaped space of the if-else block. Go to the Data&Blocks palette and drag and drop the LDR variable block inside the first space of the () < () block and write 100 in the second space.
  8. Next, go to the Robots palette and from the Arduino extension drag and drop the Set digital pin () as () block below the if arm of the if-else block. Select Pin_13_LED from the first drop-down menu and select HIGH from the second drop-down menu.
  9. Drag and drop another Set digital pin () as () block below the else arm of the if-else block. Select Pin_13_LED from the first drop-down menu and select LOW from the second drop-down menu.

Below is the complete script:

Click on the green flag to run the script.

Click on the red octagon, next to the green flag to stop the script.

This Helped
This didn't help
Close Menu
×
×

Cart

STEMpedia Starter Package is now on Indiegogo!
Get 41% OFF with Super Early Bird discounts!
x