Interface LDR with Arduino

About LDR:

A photoresistor or LDR is a light-dependent variable resistor. The resistance of a photoresistor is dependent on the light intensity, as the intensity increases resistance decreases and vice-versa.

Pinout of LDR

Components Needed

  • Arduino Uno/nano/mega
  • LDR
  • 10km resistor
  • Jumper wires

Circuit Diagram

Arduino IDE Code

const int ldr=A0;
void setup() {
  
Serial.begin(9600);
}

void loop() {
  int LDR_Data=analogRead(ldr);
  Serial.print("LDR DATA IN BITS:");
  Serial.println(LDR_Data);
  int LDR_Volt=map(LDR_Data,0,1023,0,5000);
  Serial.print("LDR DATA IN milliVolts:");
  Serial.println(LDR_Volt);
}

Leave a Reply

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