Nikhileswari
Published © GPL3+

Light Sensor Using Arduino

The Project is about switching on the light if necessary (i. e in darkness) and switching off the light when there is enough brightness.

BeginnerFull instructions provided2 hours64,691
Light Sensor Using Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

screenshot_(87)_OdyH7WqphF.png

Code

Light Sensor using Arduino

Arduino
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 <= 400)
  {
    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);
  }

}

Credits

Nikhileswari

Nikhileswari

2 projects • 5 followers

Comments