Git Product home page Git Product logo

automatic_ldr_night_lamp's Introduction

LDR_Night_Lamp

Automatic LDR Based Night Lamp.
In order to detect the intensity of light or darkness, we use a sensor called an LDR (light dependent resistor). The LDR is a special type of resistor that allows higher voltages to pass through it (low resistance) whenever there is a high intensity of light, and passes a low voltage (high resistance) whenever it is dark. We can take advantage of this LDR property and use it in our DIY Arduino LDR sensor project.

EPrototype

How Does It Work?
This system works by sensing the intensity of light in its environment. The sensor that can be used to detect light is an LDR. It's inexpensive, and you can buy it from any local electronics store or online. The LDR gives out an analog voltage when connected to VCC (5V), which varies in magnitude in direct proportion to the input light intensity on it. That is, the greater the intensity of light, the greater the corresponding voltage from the LDR will be. 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). When there is sufficient light in its environment or on its surface, the converted digital values read from the LDR through the Arduino will be in the range of 800-1023.
Furthermore, we then program the Arduino to turn on a relay. Correspondingly, turn on an appliance (light bulb), when the light intensity is low (this can be done by covering the surface of the LDR with any object), that is, when the digital values read are in a higher range than usual.

Arduino LDR Sensor Connections
First, you need to connect the LDR to the analog input pin 0 on the Arduino. You have to use a voltage divider configuration to do this. The connection diagram for the Arduino is as given below.
One leg of the LDR is connected to VCC (5V) on the Arduino, and the other to the analog pin 0 on the Arduino. A 100K resistor is also connected to the same leg and grounded.

Connections

Connecting the Relay to the Arduino
A relay is an electromechanical switch. It can be used to turn an appliance ON/OFF working on AC/DC. When the Arduino supplies HIGH voltage (5V) to the relay, it turns it on (the switch is ON), otherwise, it remains off.
In this project, we used a 5V SPDT (single pole double throw) relay. One terminal of the relay coil is connected to the Arduino's digital pin 2 and the other end to GND. We connected a light bulb to it as well. Since we are dealing with high power AC voltages, be sure to take proper precautions. If you are still confused about connecting a relay to an appliance, read this article on Relay logic. The overall circuit is shown below.

Serial

In this sketch, we set a threshold light value as 700, but it can vary for your projects. You will need to find out the particular value at which the light bulb should turn on. This needs to be done after testing it empirically. So basically, the Arduino turns on the light bulb (via the relay) whenever the light intensity falls below 700. When it is above 700, it turns the light bulb off. Here's a video showing it in action.

automatic_ldr_night_lamp's People

Contributors

sarthaksahni1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.