Skip to content

USING AN LDR SENSOR WITH ARDUINO

Advertising
Advertising
?
Creation quality: 5.0/5 (1 vote)
Evaluation of members on the printability, utility, level of detail, etc.

  • 480 views
  • 5 downloads

License
3D design format
Folder details Close
  • Nothing.obj

Learn more about the formats

Publication date 2023-09-21 at 01:31
?
Published to Thingiverse on: 2018-02-27 at 05:18
Design number 1463976

3D printer file info

3D model description

Introduction

Hi Everyone, This is my 1st Arduino's tutorial video. In this video i am going to show you how to use a LDR or Light Dependent resistor to turn on and off another circuit or a LED.

Wouldnโ€™t it be really cool if whenever a room gets dark, a light bulb automatically turns ON and eliminates the darkness? In this very simple project, I am focusing on eliminating darkness. You can even use this as an emergency lighting system.

https://www.youtube.com/watch?v=1rltou-lzyQ

Step 1: Principle

Principle
Principle
The LDR is a special type of resistor which allows a lower voltage to pass through it (high resistance) whenever its dark and higher voltages to pass (low resistance) whenever there is a high intensity of light.

We are going to use a 10k resistor along with the LDR to create a voltage divider circuit. The varying resistance of the LDR is converted to a varying voltage that the analog pin of the Arduino will then be using in its logic.

Step 2: Hardware Requirement

Hardware Requirement
For this very simple DIY Arduino project we need:

  • a breadboard
  • an arduino uno/nano (whatever is handy)
  • LED (Light Emitting Diode)
  • LDR (Photoresistor)
  • A 10K Resistor for creating the voltage divider and a 220ohm resistor for the LED
  • Few breadboard friendly connecting wires
  • and a USB cable to upload the code to the Arduino

Step 3: Assembly

Assembly
- Connect the 3.3v output of the Arduino to the positive rail of the breadboard

  • Connect the ground to the negative rail of the breadboard

  • Place the LDR on the breadboard

  • Attach the 10K resistor to one of the legs of the LDR

  • Connect the A0 pin of the Arduino to the same column where the LDR and resistor is connected (Since the LDR gives out an analog voltage, it is connected to the analog input pin on the Arduino. The Arduino, with its built-in ADC (Analog to Digital Converter), then converts the analog voltage from 0-5V into a digital value in the range of 0-1023). - Now connect the other end of the 10K resistor to the negative rail - And the second (free) leg of the LDR to the positive rail

Pretty much this is what we need for the light sensing. Basic circuits like this can be done without an Arduino aswell. However, if you want to log the values and use it to create charts, run other logics etc. I will recommend an Arduino or ESP8266 or may be a ESP32 for this.

Now, as we want our circuit to do something in the real world other than just displaying the values on the computer screen we will be attaching a LED to the circuit. The LED will turn on when its dark and will go off when its bright. To achieve this we will:

  • Place the LED on the breadboard
  • Connect the 220ohm resistor to the long leg (+ve) of the LED
  • Then we will connect the other leg of the resistor to pin number 13 (digital pin) of the Arduino
  • and the shorter leg of the LED to the negative rail of the breadboard

Step 4: The Code

The Code
const int ledPin = 13;
const int ldrPin = A0;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}

void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 200) {
digitalWrite(ledPin, HIGH);
Serial.print("Its DARK, Turn on the LED : ");
Serial.println(ldrStatus);
} else {
digitalWrite(ledPin, LOW);
Serial.print("Its BRIGHT, Turn off the LED : ");
Serial.println(ldrStatus);
}
}

https://youtu.be/1rltou-lzyQ

Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next Instructable.

Advertising


Issue with this design? Report a problem.

Would you like to support Cults?

You like Cults and you want to help us continue the adventure independently? Please note that we are a small team of 3 people, therefore it is very simple to support us to maintain the activity and create future developments. Here are 4 solutions accessible to all:

  • ADVERTISING: Disable your banner blocker (AdBlock, โ€ฆ) and click on our banner ads.

  • AFFILIATION: Make your purchases online by clicking on our affiliate links here Amazon.

  • DONATE: If you want, you can make a donation via Ko-Fi ๐Ÿ’œ.

  • WORD OF MOUTH: Invite your friends to come, discover the platform and the magnificent 3D files shared by the community!


Sharing and downloading on Cults3D guarantees that designs remain in makers community hands! And not in the hands of the 3D printing or software giants who own the competing platforms and exploit the designs for their own commercial interests.

Cults3D is an independent, self-financed site that is not accountable to any investor or brand. Almost all of the site's revenues are paid back to the platform's makers. The content published on the site serves only the interests of its authors and not those of 3D printer brands who also wish to control the 3D modeling market.

100% secure payment by credit card, PayPal, Apple Pay, Google Pay, etc.
View all payment options.