Light Sensor using Arduino

Introduction

In this project, a simple light sensor is designed using LDR. The project is built around Arduino.

Components required

  • Arduino UNO
  • Light Dependent Resistor (LDR)
  • 100 KΩ POT
  • Buzzer

Circuit Diagram

Working

A 100 KΩ POT and the LDR form a voltage divider and the output of the voltage divider is given to the analog input A0 of Arduino. A buzzer is connected to pin 11 of Arduino.

When the LDR detects a light over certain intensity, the Arduino will trigger the buzzer. When the intensity of light decreases, the buzzer is turned off.

The 100 KΩ POT used in the voltage divider network can be used to adjust the intensity levels at which the buzzer is triggered.

Code

int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
pinMode(11,OUTPUT);
}
void loop()
{
sensorValue=analogRead(sensorPin);
if(sensorValue <= 14)
digitalWrite(11,HIGH);
else
digitalWrite(11,LOW);
Serial.println(sensorValue);
delay(2);
}

This circuit is similar to dark sensor circuit using BC547 transistor.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.