World's Fastest PCB Manufacturing
My Message
Suggestions
Account

Get started now

Log In

or

Sign Up

My ALLPCB

My Orders Shipping Address Balance Account Settings My SNS Profile
0
  • Home
  • Instant Online Quote Alternate Text
    • PCB Instant Quote
    • PCB Assembly Quote
    • SMD-Stencil Quote
  • PCB Assembly
  • PCB Capabilities
  • Feedback
  • Resources
    • Sponsorship
    • PCB Softwares
    • Units Conversion
    • FAQ
  • About Us
    • About Us
    • Why Us
    • Contact Us
    • News
Log In Sign Up
  • Home
  • Instant Online Quote
    • PCB Instant Quote
    • PCB Assembly Quote
    • SMD-Stencil Quote
  • PCB Assembly
  • PCB Capabilities
  • Feedback
  • Resources
    • Sponsorship
    • PCB Softwares
    • Units Conversion
    • FAQ
  • About Us
    • About Us
    • Why Us
    • Contact Us
    • News
service@ALLPCB.com
Thank you very much for your valuable suggestion!
We will solve it as soon as possible!

An Arduino-Controlled Light Sensor

2017/1/23 18:16:25

Monitoring the output of a light-dependent resistor, or photoresistor, allows the Arduino to know how light or dark it is. When the light falls below a certain level, the Arduino turns on a couple of LEDs.
A light-dependent resistor, or photoresistor, is a sensor whose resistance decreases as the amount of light falling on it increases. When it is dark, the resistance of a photoresistor may be as high as a few MΩ. When it is light, however, the resistance of a photoresistor may be as low as a few hundred ohms.
In this experiment, we will connect a photoresistor to an Arduino analog input and read the value with the analogRead() function. Depending on the value the Arduino reads, the program will then set pin 3 HIGH or LOW to turn on or turn off the LED night lights. The threshold value is 150. When the analog value read is less than 150, the Arduino will turn the LEDs on. When the analog value it reads is below 150, the Arduino will turn the LEDs off.
Hardware Required
  • 1 x photoresistor
  • 2 x LED
  • 2 x 470 ohm resistors
  • 1 x 1 kohm resistors
  • 1 x Arduino Mega2560
  • 1 x breadboard
  • jumper wires
Wiring Diagram
You connect the components as shown in the diagram below. Connect the LEDs to pin 3 of the Arduino. The two 470 ohm resistors are current limiting resistors. One lead of the photo resistor is connected to 5V, the other to one lead of the 1 kohm resistor. The other lead of the 10 kohm resistor is connected to ground. This forms a voltage divider, whose output is connected to pin A1 of the Arduino. As the light impinging on the photoresistor gets stronger, the resistance decreases, and the voltage output of the divider increase. The reverse happens, when the impinging light gets weaker.
Setup
  1. Connect one of the two terminals of LDR to 5V and other one to the GND through a one kilo ohm resistor.
  2. Connect one end of a wire to analog pin A1 and other to 1K resistor’s non-grounded terminal.
  3. Connect two LEDs in parallel, both through a 470 ohm resistor and with negative terminal grounded as shown in above circuit diagram.
  4. Connect pin 3 to the positive terminals of LEDs through 470 ohm resistors.
  5. Connect all the grounded terminals to Arduino’s GND pin.
  6. Connect the Arduino using Arduino USB cable and upload the program to Arduino using Arduino IDE software.
  7. Provide power to the Arduino board using power supply, battery or USB cable.
If the room is lighted, the LEDs should not light. Try getting them to turn on it by covering the photoresistor with your hand. Remove your hand and observe that they turn off again.
  • 2728
  • 1
  • 249
Post Comment

    Clyde

    2017/1/25 18:16:25

    A great sharing for beginners. Thanks for your efforts and I will follow you and keep reading your posts.

    You might like

    dydzld765lebl9

    • Threads

      4

    • Following

      0

    • Followers

      0

    PCB Prototype

    PCB Instant Quote

    x mm

    Quantity

    Quote Now

    PCB Assembly

    SMT-Stencil

    • 12
    Products & Service
    PCB Capabilities
    Aluminum PCB Service
    PCB Assembly Service
    SMT-Stencil
    Quotation & Feedback
    Online Auto-Quotation
    PCB Assembly Quote
    Quote by Salesperson
    Customer Reviews
    Customer Support
    FAQ
    Community
    Sponsorship
    Referral Program
    About Us
    About Us
    Why Us
    Contact Us
    News
    Resource Details
    PCB Software
    Units Conversion
    service@allpcb.com central_support@allpcb.com
    Follow Us:
    Facebook Youtube Twitter Tumblr Youtube
    Certification: Certification
    Our Preferred Partners: Our Preferred Partners

    Please send Gerbers to service@ALLPCB.com for quotation © ALLPCB.com,All Rights Reserved Privacy PolicySitemap

    Secure Site by GoDaddy.com This site has earned the McAfee SECURE certification.