Arduino Tutorials – Lesson 8 – LDR Sensor on Arduino UNO

Creating LDR Sensor program using Arduino UNO

Required Components

  1. LED -1 no
  2. LDR -1 no
  3. Resistor 10K Ω -1 no
  4. Resistor 220 Ω -1 no
  5. Bread board -1 no
  6. Arduino UNO board -1 no
  7. Connecting cables -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Arduino UNO A0 pin to the LDR.
  3. Connect the Arduino UNO 13th pin to the LED.
  4. Connect the Arduino Uno 5V, GND to the LDR Sensor using jumper wires.
  5. Check the Arduino program.
  6. Check the circuit connections.
  7. Run the Arduino program.

Arduino Program

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<=300)
  {
    digitalWrite(ledPin,HIGH);
    Serial.print("LDR in Dark,LED is ON");
  }
  else
  {
    digitalWrite(ledPin,LOW);
    Serial.print ("LDR in Light,LED Is Off");
  }
}

Usage

  1. Alarm clocks
  2. Street lights
  3. Light intensity meters
  4. Burglar alarm circuits

Projects

  1. Shooting game

Leave a Reply

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