top of page

LDR with LED- Easiest Tutorial

  • Writer: Admin
    Admin
  • Jan 26, 2018
  • 2 min read

Hey guys! Today I am going to show you how to make an Automatic Street Light system with LDR, AKA a Photoresistor, and an Arduino UNO board. it pretty simple and is the modified version of the ReadAnalogVoltage example that come with the Arduino software. To get an idea about the project before making it, check out my YouTube video and like the video!

The materials you require are-

Arduino UNO

LDR (photoresistor)

Resistor (you can use any one in the 100ohm to the 330ohm range, I used 220 ohm)

Breadboard

Jumper Wires

How to make:

First of all, you need to understand how an LDR works. Basically it works by changing its resistance according to the light intensity that falls upon it. in daylight, it gives high resistance and in low light it gives low resistance thus the LED will glow. The below picture shows LDR as in a circuit diagram.

LDR as in a circuit diagram

So the first step to creating your LDR circuit is to make the connections. before connecting the LEDs, you will need to understand the connections. The connections are pretty simple.

Connect one end of the LDR to one end of the resistor.

Connect the free end of the resistor to Arduino GND.

Connect free end of LDR to Arduino 5V.

Connect the junction of the LDR and resistor to Arduino Analog pin A0.

This is the basic LDR circuit.

The Basic Connections

This will show the sensorValue level in the serial monitor after you upload the program code. You will have to change the sensorValue according to this value. Make the region around the ldr dark. Note down the sensorValue and change the value accordingly. You will get the hang of it once you play around with it more.

Now for connecting the LEDs:

Connect he long leg (positive) of LED to digital pin 13 on the Arduino and short leg (negative) of LED into the Arduino GND.

This is the connection. As you have seen, it is very simple. Now you will need to upload the code.

The code is as given below-

// LDR-easiest tutorial. Created by Bhuvans DIY https://www.youtube.com/channel/UC2iJaebH9PKJCLPl4Oj_VMw //Thanks to Tinkering Lab, KV No1 Palakkad,Kerala,India. // the setup routine runs once when you press reset: void setup() { pinMode(13,OUTPUT); // initialize serial communication at 9600 bits per second: Serial.begin(9600); }

// the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); Serial.println(sensorValue); if (sensorValue < 350) //change this value according to what is on the serial monitor digitalWrite(13, HIGH ); else digitalWrite(13, LOW); }

That's it for this post. we'll see you next time, and don't forget to comment and like my YouTube video!


 
 
 

Comments


Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page