kiranpaul
Published © GPL3+

Light Magic: Using LM393 and Arduino UNO

Automatic light control using a photosensitive LDR sensor module and Arduino.

BeginnerFull instructions provided37,673
Light Magic: Using LM393 and Arduino UNO

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LM393 Light-Dependent Resistor (LDR)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Get software from: https://www.arduino.cc/en/Main/Software

Story

Read more

Schematics

Circuit diagram

Code

Code_LDR

Arduino
void setup() {
  pinMode(8,INPUT);
  pinMode(9,OUTPUT);
  Serial.begin(9600); //initialise serial monitor

}

void loop() {
  int temp=digitalRead(8);      //assign value of LDR sensor to a temporary variable
  Serial.println("Intensity="); //print on serial monitor using ""
  Serial.println(temp);         //display output on serial monitor
  delay(300);
  if(temp==HIGH)               //HIGH means,light got blocked
  digitalWrite(9,HIGH);        //if light is not present,LED on
  else
  digitalWrite(9,LOW);         //if light is present,LED off
}

Credits

kiranpaul

kiranpaul

2 projects • 2 followers

Comments