How to Use an LDR Sensor With Arduino

Posted by admin 23/08/2018 1 Comment(s)

HOW TO USE AN LDR SENSOR WITH ARDUINO


Circuit Diagram :



Code

 

 

//Coded by Moudud Ahmed,Facebook- https://web.facebook.com/people/Moudud-Ahmed/100022755660713
//Powered by https://www.electronics.com.bd/

 


const int ledPin = 12;

const int ldrPin = A0;

void setup() {

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

pinMode(ldrPin, INPUT);

}

void loop() {

int ldrStatus = analogRead(ldrPin);

if (ldrStatus <=200)               //Adjust the sensitivity
{
  digitalWrite(ledPin, HIGH);

Serial.println("12th Pin is ON");

}

else {

digitalWrite(ledPin, LOW);

Serial.println("12th Pin is OFF");

}

}


 

 

 

1 Comment(s)

ashraf minhaj:
01/09/2018, 10:46:40 PM, http://ashrafminhajfb.blogspot.com
Reply

Hi, I was wondering if I could write Tutorials on your site. I write on 3 websites and on my blog but I want to write for bangladeshi people. That's why I'm asking you this.

Write a Comment