Turn LED On If Surroundings Are Dark With LDR Sensor!

Turn LED On If Surroundings Are Dark With LDR Sensor! © MIT

I decided to learn about various sensors. The first is the LDR sensor!

  • 1,769 views
  • 0 comments
  • 1 respect

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Light Dependent Resistor
×1

Apps and online services

About this project

I learned how to use LEDs, RGB LEDs and then how to use the LDR sensor to turn the LED on when the ambient light is dark!

Code

CDS CodeArduino
simple..
int led = 6;

void setup() {
  
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  
}

void loop() {
  
  int CDS = analogRead(A0);
  Serial.println(CDS);
  if (CDS > 50){
    
    digitalWrite(led, LOW);
  
    
  }
  
  else {
   
    digitalWrite(led, HIGH);
  
    
  }
}

Schematics

CDS LED Schematics
Oh..
 1mnec7ltkw

Comments

Similar projects you might like

Turn On and Off LED by LDR (Toggle LDR)

Project showcase by muhammed amar slik

  • 22,666 views
  • 1 comment
  • 14 respects

LED as a Light Sensor

Project tutorial by WolfxPac

  • 2,343 views
  • 8 comments
  • 19 respects

Ambient Light Sensor Using Photo Resistor and LED Lights!

Project tutorial by DCamino

  • 3,366 views
  • 4 comments
  • 17 respects

LED Emergency Lights using WS2812 RGB LED Module

Project tutorial by bigboystoys13

  • 10,459 views
  • 7 comments
  • 26 respects

Not Your Typical RGB LED

by Alexander Vaughn

  • 1,730 views
  • 1 comment
  • 9 respects
Add projectSign up / Login