Need help with the code of nodemcu

I working on ldr using laser based security project . with the help of node mcu . i want to do that if any unwanted access is attempted then it gives notification on my phone

but i facing issue with the code , it gives error that is -

> ldrPin' was not declared in this scope 

but i already declared it before . so anyone please help me :-

hear the code down below -

#include <ESP8266WiFi.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "fb607aaa4be245ababdba1abd1dd0f70";
/* WiFi credentials */
char ssid[] = "POCO F1";
char pass[] = "";
/* HC-SR501 Motion Detector */
#define ledPin 5 
#define ldrpin A0 // Input for HC-S501
int ldrValue; // Place to store read PIR Value
void setup()
{
  Serial.begin(115200);
  delay(10);
  Blynk.begin(auth, ssid, pass);
  pinMode(ledPin, OUTPUT);
  pinMode(ldrPin, INPUT);
  digitalWrite(ledPin, LOW);
}
void loop()
{
  getldrValue();
  Blynk.run();
}
/***************************************************
 * Get ldr data
 **************************************************/
void getldrValue(void)
{
  ldrValue = digitalRead(ldrpin);
  if (ldrValue) 
  { 
    Serial.println("==> Motion detected");
    Blynk.notify("T==> Motion detected");  
  }
  digitalWrite(ledPin, ldrValue);
}

Please read through your code line by line if necessary… we are not here to do that for you :stuck_out_tongue_winking_eye:

Different letter case

And you do not need to set a pinMode() for analog pins in the first place, unless you are changing them to Digital mode use.

Now I am facing problem with LDR sensor . My LDR sensor does not read any value . I want to do that if LDR sensor value is less than 600 then it give me a notification on my phone through blynk app . here is the full code … please help me … i need your help …

Uploading: IMG_20190225_112215.jpg… Uploading: IMG_20190225_112225.jpg…

#include <ESP8266WiFi.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "f8f7db19db7e4f93a74651591130405f";
/* WiFi credentials */
char ssid[] = "POCO F1";
char pass[] = "";
/* HC-SR501 Motion Detector */
#define ledPin 5 
#define ldrPin A0 // Input for HC-S501
int ldrValue; // Place to store read ldr Value
void setup()
{
  Serial.begin(115200);
  delay(10);
  Blynk.begin(auth, ssid, pass);
  pinMode(ledPin, OUTPUT);
 // pinMode(ldrPin, INPUT);
  digitalWrite(ledPin, LOW);
}
void loop()
{
  getldrValue();
  Blynk.run();
}
/***************************************************
 * Get ldr data
 **************************************************/
void getldrValue(void)
{
  ldrValue = digitalRead(A0);
  if (ldrValue <=600) //IF LDR VALUE IS LESS THEN 600 THEN IT GIVES NOTIFICATION ON MY PHONE
  { 
    Serial.println("==> Motion detected");
    digitalWrite(ledPin, HIGH);
    Serial.print(ldrValue);
    Serial.println("LDR is DARK, LED is ON");
   // Blynk.notify("T==> Motion detected");  
  }
  else {

     digitalWrite(ledPin, LOW);
     Serial.println("LED is OFF");

  }

 // analogWrite(ldrPin);
  digitalWrite(ledPin,ldrPin);
}

Please properly format posted code as per the Welcome Topic… I fixed your last post.

Generally we try to assist users about learning Blynk and finding documentation. Aside from a suggestion here or there… fixing or writing your code is for you to learn to do.

Google for some LDR examples in the wild web and break them down to understand how they work. then you can add in Blynk to act as a controller/GUI

Instead of calling your LDR function thousands of times a second, look at using BlynkTimer.

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-display-any-sensor-data-in-blynk-app

can you please describe me the think in brief just of because i am new in the arduino programming . If you help me I will thankful to you .

My first suggestion would be to eliminate everything having to do with Blynk.

An LDR (Light Dependent Resistor) is an analog device. You need to use analogRead,

const int ledPin =  5;
const int ldrPin = A0;

void setup(void) {
   pinMode(ledPin, OUTPUT);
   pinMode(ldrPin, INPUT);
   digitalWrite(ledPin, LOW);
}

void loop(void) {
   getldrValue();
}

void getldrValue(void) {
   int ldrValue = analogRead(ldrPin);
   if (ldrValue <= 600)
      digitalWrite(ledPin, HIGH);
   else
      digitalWrite(ledPin, LOW);
}

Note: I didn’t test this. And as @Gunner suggested, move getldrValue() to a timer.